Get WordPress Custom Post Taxonomy Categories and Tags

Here's another problem with WordPress post where you want to know whether a particular custom post has a particular taxonomy categories or tags. In a normal post cast, you will highly likely used either get_categories or get_terms but for custom post type you might need to use another method which is what i am using currently as well. In order to determine whether a post category or tag is used by your custom post type, try the following

$terms = wp_get_object_terms($post->ID, 'review_category');

The first parameter is obviously the post id but the second parameter here is actually the custom post type taxonomy which you can find on your custom post type 'categories' section (on the url). Once you have determine your taxonomy name, getting post taxonomy categories or tags should be a piece of cake.

Share
Livedrive Simple, Secure Online Backup Increase sales with social commerce at BigCommerce. Learn More!

One thought on “Get WordPress Custom Post Taxonomy Categories and Tags

  1. Hey Clay,
    I was wondering on a similar note,, WordPress is turning 7 years old this year and is currently the most popular blog publishing application available today. Over 200 million websites are using WordPress, but it can be a bit difficult to tell because of how easy WordPress customization is. Through the use of templating and widgets integration, WordPress blogs can be customized to the web master's liking and they do not even need to know PHP and HTML coding although those that know can benefit even more. Therefore it is important to make full use of the WordPress customization techniques to make the most out of your blog.
    I'll be back to read more next time

Comments are closed.