get a list of posts from Custom Taxonomy

Check out the Taxonomy Parameters.

<?php
$args = array(
    'post_type' => 'product',
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'tax_query' => array(
        array(
            'taxonomy' => 'taxonomy_name',
            'field' => 'id',
            'terms' => '22'
        )
    )
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
    //content
endwhile;
?>

Leave a Comment