Get Custom Posts for Custom Taxonomies & Terms

Get Custom Posts for Custom Taxonomies & Terms

Taxonomies are basically a way of grouping data in WordPress. In WordPress, the most common default taxonomies are ‘categories’ or ‘tags’ those has the grouping posts and these are named & recorded in the WordPress database as ‘category’ and ‘post_tag’ respectively. Specific categories or tags are called terms.

For the query of Custom post type in WordPress and return posts based on these custom taxonomy names and terms, we can use ‘tax_query’ within get_posts() as indicated below:


In the above query we have shown the ‘music’ custom query post having custom taxonomy name ‘album’ & the terms names is ‘hot’. The below functions also produce the same output:


Now, if we want to display more or multi terms in ‘album’ taxonomy then we have to use array for the terms & must user operator for the query:

The same above query can be followed by term id if you don’t know the slug. Just used below code then:


Now, we will show NOT IN operator where all the post will be displayed EXCEPT ‘hot’ & ‘cool’ terms. Follow the below code:


I think, so far you understand all the above code and hope can find your way to display custom taxonomy post from custom post type. In the final code i am going to show you how to display post from multi taxonomy:

Hope all the examples code above demonstrate nice solution for your theme/ plugin development. Still if you have question feel free to drop message below.


This post has already been read 2034 times!

Mehedi Hasan

Cool WordPress Developer having much agile experience to develop any kind of WordPress sites & plugins. Also good in troubleshooting, fixing & making any kind of tweaks for WP site.

More Posts

POSTED ON: Wordpress Development
TAGGED : , ,

One thought on “Get Custom Posts for Custom Taxonomies & Terms”

  1. Explore the best essay writing resources for high school students. . know plus writing prompts. ABC’s of the Writing Process Writing help from the beginning to .
    custom essay writing online
    24 Jan 2015 . Sat Essay Writing Help Novel The low unemployment that Hong Kong that exports have can indicate problems with the liver in turn increasing .

Leave a Reply

Your email address will not be published. Required fields are marked *