Adding custom fields to categories
In addition to specifying names for categories, it may be useful to attach additional information to custom taxonomies created in a WordPress plugin. For example, we may want to assign custom colors to categories that will be used when they are displayed, or we might want to identify the categories of content that are only accessible to paying members on a website.
Getting ready
You should have already followed the Adding custom categories for custom post types recipe to have a starting point for this recipe, and the resulting plugin should still be active on your development site. Alternatively, you can get the resulting code (ch4/ch4-book-reviews/ch4-book-reviews-v6.php
) from the book's GitHub page and rename the file ch4-book-reviews.php
.
How to do it...
- Follow these steps to display additional fields in the taxonomy editor and learn how to store the additional data in the site's database:
- Navigate to the
ch4-book...