How to prevent new terms being added to a custom taxonomy?

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

Leave a Comment