Query Post Terms by Taxonomy and Post Type

One of the grate feature of wordpress is to give us access in making custom post type and categories under it. And under each category (taxonomy) we can group them as terms.

It sounds cool and exciting but as I search the internet, I can’t find a way to query post it under these condition. I’m lucky I fount one, and I’ll share it to you here.

The code below will show a posts under resources post type with a taxonomy resourcesCategory, and a term event.

<?php query_posts(
          array('post_type' => 'resources', 
                'showposts' => 1, 
                'tax_query' => array(
                     array(
                    'taxonomy' => 'resourcesCategory',
                    'field' => 'slug',
                    'terms' => 'event'
                     )
                                    )
                ) 
                );
?>

The key here is the tax_query line. This line of code classify the condition for the taxonomy.