Priority of Meta Box for Custom Post Type

I’m having a small issue with the custom post type entry screen. I’d like to bump up my metabox right under the content box, but I’m not sure if that’s even possible (as the metaboxes in between are “defaults”, i.e.; Excerpt, Discussion & Author).

I’m applying the standard code:

function ctp_admin(){
add_meta_box('cpt_meta', 'Meta Box', 'cpt_meta', 'cpt_function', 'normal', 'high');
}

Thank you!

Noel

1 Answer
1

Where you have the parameter ‘normal’ eg. the context parameter change that to read ‘core’.

add_meta_box('cpt_meta', 'Meta Box', 'cpt_meta', 'cpt_function', 'core', 'high');

The default meta boxes are registered as core and are listed first, followed by the ‘normal’ context. The docs don’t actually say you can do it but I have done without any problems.

EDIT:
Make sure your function is registered on the ‘add_meta_boxes’ hook with a high priority eg:

function my_metabox() {
    ...
}
add_action( 'add_meta_boxes', 'my_metabox', 1 ); // priority 1

The use of ‘core’ vs. ‘normal’ may not actually make a difference in the latest version.

Leave a Comment