Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've created some custom taxonomies using register_taxonomy, but I want to prevent new terms from being added. I noticed that there is a 'capabilities' argument available in register_taxonomy, is that what I should be using and if so, how would I use it?

Here's some of my code, I'm using a plugin I created to add the taxonomies (hence the public static function part). Is there an easy way to prevent new terms being created for my taxonomy?



public static function register_directory_styles_taxonomy()
        $labels = array(
            'name'                      => 'Music styles',
            'singular_name'             => 'Music style',
            'search_items'              => 'Search music styles',
            'all_items'                 => 'All music styles',
            'parent_item'               => 'Parent music style',
            'edit_item'                 => 'Edit music style',
            'update_item'               => 'Update music style',
            'add_new_item'              => 'Add new music style',
            'new_item_name'             => 'New music style',
            'choose_from_most_used'     => 'Choose from most used music styles'

        $args = array(
            'hierarchical'  => true,
            'labels'        => $labels,
            'rewrite'       => false
            // 'show_ui'        => false

        register_taxonomy( 'ibmstyles', 'ibmdirectory', $args );
share|improve this question
Why do you comment out 'show_ui' => false? –  gmazzap Sep 3 '13 at 11:03
You are on the right track with capabilities. You can take a additional look at, because there is a little bit mor information as on the Besides that, this:… and this:… might help you. At the latter especially the link in the answer. –  ialocin Sep 3 '13 at 11:35

1 Answer 1

up vote 8 down vote accepted

You can block addition of new terms with a filter on pre_insert_term. The source is helpful in working out what you can do.

add_action( 'pre_insert_term', function ( $term, $taxonomy )
    return ( 'yourtax' === $taxonomy )
        ? new WP_Error( 'term_addition_blocked', __( 'You cannot add terms to this taxonomy' ) )
        : $term;
}, 0, 2 );
share|improve this answer
you are just one of the best! learned something - again. Additional thought: combine that with current_user_can() or user_can() for some Role and Capability management. –  ialocin Sep 3 '13 at 15:04
Fantastic answer, thanks s_ha_dim and ialocin for your comments –  Osu Sep 4 '13 at 10:46
Thanks @s_ha_dum - cheers –  Brandt Solovij Oct 9 '13 at 19:00

Your Answer


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.