Press "Enter" to skip to content

Limiting a taxonomy to only having 1 term checked

One thing I dislike about WordPress taxonomies is that there is no built in way to limit a post to only having 1 term for a certain taxonomy.  You always have to have a metabox with all the terms shown alongside checkboxes, and it allows you to check as many as you want.

Sometimes you might want to limit 1 term from a taxonomy. A really quick way to do that is with the following piece of code you can put in your functions file:

This effectively prevents the user from selecting more than 1 term on a post. It will unselect everything if you attempt to check another. It’s not foolproof, but for the casual user it should be adequate in what you need.

    Leave a Reply