Adding custom categories for custom post types
To keep items organized on a site, administrators often use the built-in WordPress categories and terms to identify similar items. Looking back at the book review system that we have been putting in place so far in this chapter, a type of categorization that would be helpful to add is a book type (for example, science fiction, documentary, fiction, and poetry).
Getting ready
You should have already followed the Displaying custom post type data in shortcodes 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-v5.php
) from the book's GitHub page and rename the file ch4-book-reviews.php
.
How to do it...
Follow these steps to create a new category (known as a taxonomy in the WordPress backend) and associate it with the book review custom post type.
- Navigate to the...