Adding content to a taxonomy metabox

I want to add some custom content to the default metabox for a custom taxonomy. Ideally I’d be able to insert this content above the tag cloud where it says Choose from the most used [tag]s.

Is there a “best practice”-compliant way to do this in WordPress? For example, is there a way to do this without removing and re-adding a clone of the taxonomy metabox, which is the method I’ve seen recommended for similar situations on WPSE and elsewhere? That seems like a bit of a blunt approach in this case.

Read More

I know I can insert the content with javascript, or use a separate metabox, but I’m wondering if there’s a hook for this sort of task.

Related posts

Leave a Reply

1 comment

  1. From core:

    function post_tags_meta_box($post, $box) {
        $defaults = array('taxonomy' => 'post_tag');
        if ( !isset($box['args']) || !is_array($box['args']) )
            $args = array();
        else
            $args = $box['args'];
        extract( wp_parse_args($args, $defaults), EXTR_SKIP );
        $tax_name = esc_attr($taxonomy);
        $taxonomy = get_taxonomy($taxonomy);
        $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
        $comma = _x( ',', 'tag delimiter' );
    ?>
    <div class="tagsdiv" id="<?php echo $tax_name; ?>">
        <div class="jaxtag">
        <div class="nojs-tags hide-if-js">
        <p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
    

    As you can see, there is no hook. So the only options are JavaScript or a clone of the metabox.

    Third option: Open a Trac ticket and ask for a new hook.

    You could also use output buffering, but I don’t recommend that, especially on that page.