WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 codex.wordpress.org/Function_Reference/register_post_type, because there is a little bit mor information as on the codex.wordpress.org/Function_Reference/register_taxonomy. Besides that, this: wordpress.stackexchange.com/questions/16588/… and this: wordpress.stackexchange.com/questions/21411/… might help you. At the latter especially the link in the answer. – ialocin Sep 3 '13 at 11:35
up vote 9 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() codex.wordpress.org/Function_Reference/current_user_can or user_can() codex.wordpress.org/Function_Reference/user_can for some Role and Capability codex.wordpress.org/Roles_and_Capabilities 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
Do I add the above code into my functions.php by itself? – Pete Jun 23 at 11:30

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.