Changing the priority of a custom taxonomy’s metabox

As is often the case in WP, there are a number of ways to attack this problem. Here’s one possible way:

function my_meta_box_order() {
    global $wp_meta_boxes;
    $genre = $wp_meta_boxes['post']['side']['core']['genrediv'];
    unset($wp_meta_boxes['post']['side']['core']['genrediv']);
    $wp_meta_boxes['post']['side']['core'] = array('genrediv' => $genre) + $wp_meta_boxes['post']['side']['core'];
}
add_action('add_meta_boxes_post', 'my_meta_box_order');
# We're hooking into: do_action('add_meta_boxes_' . $post_type, $post);

$wp_meta_boxes holds all the meta box information. It’s arranged like, $wp_meta_boxes[$page][$context][$priority][$id]. You can manipulate it as desired to rearrange your boxes. Note that this can be overridden via drag + drop, of course.

For reference, here are a number of hooks you can latch onto:

do_action('add_meta_boxes', $post_type, $post);
do_action('add_meta_boxes_' . $post_type, $post);
do_action('do_meta_boxes', $post_type, 'normal', $post);
do_action('do_meta_boxes', $post_type, 'advanced', $post);
do_action('do_meta_boxes', $post_type, 'side', $post);

Cheers~

Leave a Comment