Changing the priority of a custom taxonomy’s metabox

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.

Read More

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! 🙂

Related posts

Leave a Reply

1 comment

  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~