WordPress Custom Post Taxonomies

Custom post taxonomies in WordPress are little different from post tags and categories. To borrow the words found in a reply to an inquiry email I sent to WordPress lead developer Mark Jaquith, “taxonomies are used to tie groups of posts (or any content type) together, and come with a URL structure to access them.”

I have previously covered the process of Installing Custom Taxonomies in WordPress Themes. In that post, I not only detailed what custom taxonomies are, but I also explained the difference between custom fields and custom taxonomies. In short: custom taxonomies can be used cross-post while custom fields are only meant to input data specific to one post. What does that mean?

Jaquith put it this way:

Do you want URLs to query posts by metadata? You want a taxonomy. Do you just want to display largely unique metadata about a post? Custom fields.

The ambiguity arises from the fact that custom post taxonomies and custom fields both perform the same function (displaying custom meta data for a post); but while they perform the same function, the custom post type is limited in the sense that the inputed data cannot be accessed on other post pages.

Using Custom Taxonomies

By adding data (or “tags”) to your custom taxonomies in the post editor, you can then display that data in your posts and style them much like post tags and categories. You will notice a menu item named after your registered custom taxonomy under the Posts menu in the WordPress Admin CP. By Clicking on that, you can view a page that is almost identical to your Post Tags page in Admin CP.

wordpress custom taxonomy page WordPress Custom Post Taxonomies

As is with post tags and categories, managing custom taxonomies is easy. You can edit previously inputed taxonomies (one at a time or by bulk) by clicking on the values in the list on the right-hand side of the taxonomy page. You can also add new taxonomy values by filling in the Name, Slug and Description fields and then clicking Add New Tag.

Currently, you can not designate which post a custom taxonomy value belongs to within the custom taxonomy page in admin CP. To change the posts that a taxonomy value associates with, you must navigate to the post editor of the post you wish to add/remove values and input your values in the custom taxonomy menu in the right-hand sidebar. The menu looks like this:

wordpress 3 custom taxonomies WordPress Custom Post Taxonomies

Why Are My Custom Taxonomies Not Showing?

There are a number of reasons why your custom taxonomies may not be showing in your post pages. Below are some of the most common reasons why taxonomies are not working as well as some things to try:

  • The taxonomy was not properly installed. To install a taxonomy, you must insert code into two theme files: functions.php (which registers the custom taxonomy with the WordPress core) and the template file that will ultimately be viewable to visitors (either index.php, single.php or page.php in most cases). Read the Blogtap tutorial on installing custom post taxonomies if you need help installing taxonomies.
  • You may not have inputed values for your custom taxonomy. Taxonomies can only be displayed if values are inputed in the post editor. Remember that values are post specific, unless you want them to function otherwise (which involves hard-coding of course).
  • In the functions.php code that you use to register your taxonomy, try changing “hierarchical’ => true” to “hierarchical’ => false” and vice versa. This determines whether or not the taxonomies will act like post tags or categories.
  • Try disabling all of your plugins. A plugin may be interfering with your taxonomy.
  • Try changing themes and re-installing the taxonomy. Although this might be a little bit of a hassle, you will at least be able to isolate the problem. If taxonomies work on a separate them the you know something is coded improperly in your theme.
  • Make sure you are upgraded to the most current version of WordPress. Some older versions of WordPress do not have support for custom taxonomies.

If you are having difficulty with custom taxonomies, don’t hesitate to leave a comment and I will be sure to help you out.

Tags: , , , ,


You might like:

10 Responses to “WordPress Custom Post Taxonomies”

  1. Alan says:

    That’s a great guide, thank you very much!
    I had the problem with the functions.php, but I got it solved now.

  2. I never would have known how Taxonomy functions until I’ve read this post. It’s informative but I don’t think I’ll be needing this added patch on my sites.

  3. Taxonomies are amazing. I am still trying to work with it but I am close to mastering it. I always come to blogtap to find answers and you have just answered a ton of questions that I had.

  4. Well this post made me knew about taxonomy functions. I’ve heard about it but didn’t knew what its about. Thanks for the post!

  5. Jan says:

    I have read about taxonomy functions but never really understood what the benefit was to using them. I’m not ready (I mean I am not yet advanced enough) to need to use them yet but I can see a time down the track when I will be needing, and benefiting, from them.

    Jaquiths mud-map was very helpful:
    “Do you want URLs to query posts by metadata? You want a taxonomy. Do you just want to display largely unique metadata about a post? Custom fields.”

    Thanks for an informative post :-)

  6. Mathew says:

    I really need to read about taxonomy functions. Thanks for sharing this information.

  7. Nuwanda says:

    Hi, Chris

    “Do you want URLs to query posts by metadata? You want a taxonomy. Do you just want to display largely unique metadata about a post? Custom fields.”

    Heh, well, both.

    Here’s my thing: I’m designing a small real estate sales website. I’ve got a custom post type for listings. I’ve created a custom taxonomy for the construction type, you know, brick, concrete, timber.

    That’s all fine so far. But what I need to do is create inputs for the taxonomy.

    In the case of my construction type, I need a select (dropdown) that allows the selection of only one type.

    Other terms will need other types of inputs: text, radio, etc.

    This is pretty easy to do with the meta box functions (essentially custom fields), but I can’t see how to it with taxonomies.

    Any suggestions?

    I’m hard-coding all of this.

  8. Henry says:

    Very helpfully Article for me, thanks from germany =)

  9. David says:

    I have a very unique problem with my custom taxonomies. They appear and work properly in every way they should with one exception, unless I am logged in as the primary admin (the admin account that I created when I installed WP) then I cannot add custom taxonomies to a custom menu. I can edit and rearrange the ones that are already there, but am unable to add more to the menu.

    I have tried disabling all my plugins and even swtiching back to the Twenty-ten theme, neither one of these seem to have made a difference. Only the primary admin account can add custom taxonomies to the menu. No one else can reguardless of role.

    Thanks for any help you may be able to shed on this!

  10. Musti says:

    Hi I have registered a custom post type with two taxonomies. One is hierarchical and the other normal. I could not find out how to filter my custom posts with the non hierarchical taxonomy. Any help would be very much appreciated

Leave a Reply

*