8

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?

1 Answer 1

16

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.
0

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.