Limit taxonomy term count

plugin banner

Allows passing a "limit" attribute to the register_taxonomy() function. This makes it possible to limit the number of
taxonomy terms users a …

Author:Felix Eve (profile at wordpress.org)
WordPress version required:4.7
WordPress version tested:4.9.25
Plugin version:1.0
Added to WordPress repository:23-10-2018
Last updated:23-10-2018
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:1
Plugin URI:
Total downloads:676
plugin download
Click to start download

By default WordPress does not allow you to limit how many taxonomy terms can be attached to a post.
Enabling this plugin allows the use of the “limit” attribute when initially calling register_taxonomy().
If the limit is set to 1 then only one term can be added to the post. If the limit is greater than one then that many
terms may be added to the post. If the limit is attribute is not set, or it’s set to -1 this plugin has no effect.

Example code showing the use of the limit attribute:

register_taxonomy('artists', 'art_work', [
    'label'             => 'Artists',
    'show_ui'           => true,
    'limit'             => 1,
]);

This example shows the use of a custom taxonomy called “artists” and the post type is “art_work”.

Here is another example but this time it’s editing the previously registered taxonomy “post_tag”:

// First load the taxonomy
$taxonomy = get_taxonomy('post_tag');

// Edit it to only allow 2 tags to be added per post
$taxonomy->limit = 2;

// Re-save it with our updated settings (note casting the object to an array before saving)
register_taxonomy('post_tag', 'post', (array)$taxonomy);

FAQ
ChangeLog