Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the spinupwp domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /sites/coreysalzano.com/files/wp-includes/functions.php on line 6121
Hiding Specific Terms When Creating or Editing Posts – Corey Salzano

Hiding Specific Terms When Creating or Editing Posts

The WordPress block editor uses the REST API to manipulate all information in the post object, so hiding terms from the category, tags, or a custom taxonomy meta box can be achieved by removing those terms from REST API responses.

One hook that makes this easy is the rest_{taxonomy}_collection_params filter.

Here is an example that shows how terms can be included in the editor only if they have a certain value for a term meta key. This isn’t the best code design because it uses a global variable to hold the taxonomy name, but that’s an artifact of my pulling this out of a larger class.

For my application, the terms I’m excluding are outdated and won’t be added to any new content on the site. This method is effective and seems low risk. If you are aware of any risks associated with excluding terms from REST API responses, please comment below.