Query by Custom Taxonomy

<?php $the_query = new WP_Query( array(
    'post_type' => 'available_colors',
    'tax_query' => array(
        array (
            'taxonomy' => 'color_category',
            'field' => 'slug',
            'terms' => 'bag-colour',
        )
    ),
) );

while ( $the_query->have_posts() ) :
    $the_query->the_post();
   ?>
  <?php the_title();?><br />
<?php endwhile;

/* Restore original Post Data 
 * NB: Because we are using new WP_Query we aren't stomping on the 
 * original $wp_query and it does not need to be reset.
*/
wp_reset_postdata();
?>

Leave a Reply

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