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 );

2 Answers 2


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 );

It would seem the easiest way to do this has been answered here.

The solution was modifying the taxonomy's capabilities array:

'capabilities' => array(
    'manage_terms' => '',
    'edit_terms' => '',
    'delete_terms' => '',
    'assign_terms' => 'edit_posts'
  • 1
    This is a MUCH better/cleaner solution than the accepted one. Doing it this way removes the option from the interface entirely.
    – dmatamales
    Commented Feb 3, 2023 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.