2

How would you make a meta box sit above all other meta boxes at all times in a custom post type?

For example:

add_meta_box ( 
    'aisis-meta-id', 
    'Mini Feeds Information', 
    array(&$this, 'aisis_mini_feeds_info'), 
    'mini-feed', 
    'advanced', 
    'high' 
);

Create a meta box, how ever it only appears after ALL other meta boxes, be they plugin or system wide. I need my meta box to sit directly under the editor at all times.

3
  • For one, 'normal' takes precedence over 'advanced'. Apr 7, 2013 at 21:48
  • it was normal before, I switched it to advanced thinking it would be the opposite of what you said. Even as normal it appears UNDER the rest of the meta boxes. @JohannesPille - But ill switch it back.
    – TheWebs
    Apr 7, 2013 at 21:50
  • That's why I commented and didn't answer. Certainly ain't a complete solution. But it's true, nonetheless. If you care, try to add 2 metaboxes, give one 'advanced' and the other 'normal'. Observe their order. Apr 7, 2013 at 21:54

1 Answer 1

5

Change advanced to normal, this will at least move it up above some others.

However, there's no guarantee you get the top spot, because a user can still drag and drop metaboxes around, or a core metabox or one added by another plugin might believe it is more important than yours.

There's no way for WordPress could offer the top spot as an option, as what would happen when two plugins decided they both wanted it?

p.s. here's how to move Yoast's SEO plugin metabox down:

add_filter( 'wpseo_metabox_prio', 'move_yoast_metabox_down' );

function move_yoast_metabox_down( $priority ) {
    return 'low';
}
3
  • Well the whole reason for this was because some plugins I have used or currently use, like yoast seo, add their meta box as always number one, my meta box is then number 2....when I need it to be number one.
    – TheWebs
    Apr 7, 2013 at 22:01
  • 1
    Yoast's SEO plugin provides a filter called wpseo_metabox_prio that allows you to change its priority Apr 7, 2013 at 22:08
  • 1
    I've just added some code to my answer to show how to use this. Apr 7, 2013 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.