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'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! :)

share|improve this question
    
You mean change the default location? Because you can just drag and drop the taxonomy metabox to where you want it to appear... –  m0r7if3r 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

1 Answer 1

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~

share|improve this answer

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.