Hierarchical Taxonomies

Hierarchical taxonomies are like categories. They can have parents and children, and the meta box on the Post ^ Edit screen looks just like the category box.

For the book series site, you might want your users to classify things in fine-grained subgenres, not just the major categories one would find in a bookstore. To do this, just add one line of the register_taxonomy() arguments, as shown in Listing 12-3. Since helps ("Separate genres with commas") are not shown for hierarchical taxonomies, remove that argument.

Listing 12-3. Changing Genres to a hierarchical taxonomy register_taxonomy( 'genre', 'post', array(


Figure 12-5 shows a post with the altered Genres taxonomy meta box. You've added a few more genres, too. The Categories meta box is still present; here, it's just out of view, near the bottom of the screen. Figure 12-6 shows the management screen for the Genres taxonomy, which now looks just like the category management screen.

Figure 12-5. A hierarchical taxonomy in Post — Edit

Figure 12-6. The management screen for the Genres taxonomy

Was this article helpful?

0 0

Post a comment