Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was wondering if there were any cut and dry rules to placing meta boxes? I have a meta box for a custom post type for a TV series that holds extra information for said series: when it began airing, genre, etc and I'm debating whether to place it under the editor or on the side. Are there any unofficial rules to what kind of meta box goes where or is it up to the developer's discretion?

share|improve this question

1 Answer 1

up vote 12 down vote accepted

It is hard to declare best practices here.

The placement depends on the content of the metabox: an editor field would be too narrow usually in the side column; two small checkboxes on the other hand will look lost in the main column.

To understand where which box will be placed, let’s use a small demo plugin:

add_action( 'add_meta_boxes_post', 'register_demo_metaboxes' );

function register_demo_metaboxes()
{
    $contexts   = array ( 'normal', 'advanced', 'side' );
    $priorities = array ( 'high', 'sorted', 'core', 'default', 'low' );

    foreach ( $contexts as $context )
        foreach ( $priorities as $priority )
            add_meta_box(
                "demo-$context-$priority", // id
                    "$context/$priority", // title
                    'demo_metabox_callback', // callback
                    NULL, // screen
                    $context,
                    $priority
            );
}
function demo_metabox_callback( $object, $box )
{
    static $count = 1;
    print "number " . $count++;
}

enter image description here

side/high and side/sorted will be placed above the Publish box, normal/high immediately after the editor, */low at the end of the screen and probably out of sight.

Some rules I try to follow:

  • Do not move the Publish box. Users might not figure out how to move the box down. This can be very annoying.
  • Try to understand how often a box might be used. A setting you turn on or off just one time per post should be very low.
  • Order by importance: boxes with required fields (price of a product) should be very prominent, a description that will be extracted from the main content if empty, doesn’t have to be visible all the time.
  • Some users will move the box out of sight, some might disable it completely. Prepare your callback handlers for that.
  • Use normal/default or side/default if you are not sure.
share|improve this answer
    
Fair enough. Thanks for the explanation on which setting does what in add_meta_box. –  Manny Fleurmond Dec 25 '12 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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