4

I'm creating a new custom taxonomy (not a custom post type). On the edit post page, this custom taxonomy is showing up above all of my other meta boxes. I'd like it to sink down lower in the group.

I know that the priority can be added via add_meta_box(). Unfortunately, I'm using the default meta box created by my call to register_taxonomy(), so I have no way of changing the priority value.

How can I change the priority of my custom taxonomy so that its associated meta box appears lower in the group of meta boxes?

Thanks! :)

  • 1
    You mean change the default location? Because you can just drag and drop the taxonomy metabox to where you want it to appear... – mor7ifer Jan 31 '12 at 0:45
  • Yes, thank you - Unfortunately, I need the box to default to a specific location when my plugin is installed. :) – rinogo Jan 31 '12 at 6:47
4

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~

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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