First register your meta box with $context ‘advanced’ and $priority ‘high’

1
add_meta_box( 'my_metabox_id', 'my_metabox_title', 'my_callback', 'post_type', 'advanced', 'high' );

Then use the hook edit_form_after_title to print the metaboxes with do_meta_boxes function and unset them so they don’t display twice. It will move all metaboxes on the screen with an advanced context.

1
2
3
4
5
6
7
8
add_action('edit_form_after_title',  array( $this, 'move_metabox_after_title' ) );
 
function move_metabox_after_title () {
    global $post, $wp_meta_boxes;
 
    do_meta_boxes( get_current_screen(), 'advanced', $post );
    unset( $wp_meta_boxes[get_post_type( $post )]['advanced'] );
}

Source found here.

Move meta box after the title
Tagged on:

Leave a Reply

Your email address will not be published. Required fields are marked *