WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Inside of a Wordpress category metabox or any custom taxonomy box for that matter there is a link with the text "+ Add New Category" is there a way this link can be removed preferably without resorting to JS or CSS hacks to hide it? A way to hide it using some kind of filter or action hook would be best.

If no action hook or filter method exists to remove it, I would be open to JS and CSS solutions as a last resort.

The reason I am doing this is because I have a Wordpress installation integrated with Magento and I am creating and populating a custom taxonomy called "brands" with a list of brands from the Magento database so a post can be assigned to a brand. Obviously this means I don't want users to be able to add in their own terms and only be able to choose the brands added in dynamically to keep it in-sync with Magento.

Thank you.

share|improve this question
up vote 12 down vote accepted

The default metaboxes are registred in the file wp-admin/includes/meta-boxes.php. There you can find the function post_categories_meta_box() which will generate the taxonomy metabox. Currently there is no hook available to filter the output. But you can do one of the following:

  1. Use remove_meta_box() to remove the existing category metabox and register your own with add_meta_box(). Copy&Past the existing code to your new metabox function and remove the code block from line 345 to 367.
  2. The cleaner way: Remove the edit_terms capability from your user roles with remove_cap(). If you look in the metabox function, on line 345 you can see an if-statement which checks if the user has the capability edit_terms. If so, the + Add New XY will be displayed. Problem here, the name of the capability is dynamic and could be anything. If someone registers a taxonomy with a different capability naming, this will probably not work (untested).
share|improve this answer
Ah, yes. Capabilities is a nice way actually. However I don't want to remove the ability from other taxonomies just one in particular. I decided hiding the link with some good old fashioned CSS was the easiest choice. Thanks for the great suggestions. – Dwayne Charrington Sep 22 '11 at 23:13
I can't comment on rofflox's post, but the capability looks to have been changed to "manage_categories" – pkmatte Apr 9 '14 at 18:47

protected by Community Feb 29 at 15:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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