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 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.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

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.