What is the “Advanced” $context in add_meta_box?

The difference between normal and advanced is that normal will be placed on the page before advanced.

For example the following will display “One” before “Two”

function admin_init_test() {
    add_meta_box('one', __('One'), 'test_one', 'post', 'advanced');
    add_meta_box('two', __('Two'), 'test_two', 'post', 'normal');
}
add_action('admin_init', 'admin_init_test');

function test_two() {
    echo "<p>test_two</p>";
}
function test_one() {
    echo "<p>test_one</p>";
}

If you switch the context parameter around, then “Two” will display before “One” on the edit page:

add_meta_box('one', __('One'), 'test_one', 'post', 'normal');
add_meta_box('two', __('Two'), 'test_two', 'post', 'advanced');

Also if you reorder the meta boxes yourself by dragging them around then that order is saved and seems to take precedence over the ‘normal’ and ‘advanced’ contexts.

Leave a Comment