Avatar of Sascha Koeth
Sascha Koeth
Flag for Germany asked on

Wordpress: Move Featured Image Meta Box to the left column

How can I move the default Featured Image Meta Box position from the right column to the big left column, by using a php script or existing plugin. It should be moved right under the title for all Post Types including custom post types, not only for a specific Post Type?

WordPressPHP

Avatar of undefined
Last Comment
Sascha Koeth

8/22/2022 - Mon
Sascha Koeth

ASKER
This is the code snippet I found:

/* Move Featured Image Below Title */
function move_featured_image_box() {
remove_meta_box( 'postimagediv', 'post_type', 'side' );
add_meta_box(
'postimagediv', __('Featured Image'),
'post_thumbnail_meta_box', 'post_type', 'normal', 'high');

}
add_action('do_meta_boxes', 'move_featured_image_box');

Open in new window

The problem here is the 'post_type' ... as far as I understand this it has to be specified. But I would love to apply it to ALL post types.
Alicia St Rose

Are you using Classic editor or the default Block editor (formerly called Gutenberg)?
Sascha Koeth

ASKER
I am using classic editor.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Scott Fell

When I googled your code, it points to this article, https://www.thepixelpixie.com/move-featured-image-meta-box-custom-post-type/.  This is about updating the admin area. Is that what you expected?

If this is for the front end, are you using a standard theme or something else?

Another option is to place the page in your child them and update as you like. As example, twenty nineteen content-page.php
<?php
/**
 * Template part for displaying page content in page.php
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package WordPress
 * @subpackage Twenty_Nineteen
 * @since Twenty Nineteen 1.0
 */


?>


<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
   <?php if ( ! twentynineteen_can_show_post_thumbnail() ) : ?>
   <header class="entry-header">
      <?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
   </header>
   <?php endif; ?>


   <div class="entry-content">
      <?php
      the_content();


      wp_link_pages(
         array(
            'before' => '<div class="page-links">' . __( 'Pages:', 'twentynineteen' ),
            'after'  => '</div>',
         )
      );
      ?>
   </div><!-- .entry-content -->


   <?php if ( get_edit_post_link() ) : ?>
      <footer class="entry-footer">
         <?php
         edit_post_link(
            sprintf(
               wp_kses(
                  /* translators: %s: Post title. Only visible to screen readers. */
                  __( 'Edit <span class="screen-reader-text">%s</span>', 'twentynineteen' ),
                  array(
                     'span' => array(
                        'class' => array(),
                     ),
                  )
               ),
               get_the_title()
            ),
            '<span class="edit-link">' . twentynineteen_get_icon_svg( 'edit', 16 ),
            '</span>'
         );
         ?>
      </footer><!-- .entry-footer -->
   <?php endif; ?>
</article><!-- #post-<?php the_ID(); ?> -->

Open in new window

If you name a new file in your child them with the same content-page.php and then change the layout as you like.

In the latest wordpress themes, the thumbnail is at the top of the page though. This is why it is good to know what theme you are working with. Also, depending on the theme, there may already be an option. 
Sascha Koeth

ASKER
Hi Scott, thanks for your detailed reply! I discovered the build in drag and drop functionality in the current wordpress version ;)
ASKER CERTIFIED SOLUTION
Sascha Koeth

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.