Link to home
Start Free TrialLog in
Avatar of Sascha Koeth
Sascha KoethFlag 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?

Avatar of Sascha Koeth
Sascha Koeth
Flag of Germany image

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.
Avatar of Alicia St Rose
Are you using Classic editor or the default Block editor (formerly called Gutenberg)?
I am using classic editor.
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. 
Hi Scott, thanks for your detailed reply! I discovered the build in drag and drop functionality in the current wordpress version ;)
ASKER CERTIFIED SOLUTION
Avatar of Sascha Koeth
Sascha Koeth
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial