Reputation: 1779
How can I do the wordpress post loop, using a custom post type, to display only post from a certain category of a custom taxonomy?
$args = array(
'post_type' => 'news',
'taxonomy' => 'newscat',
'field' => 'slug',
'terms' => 'news',
'posts_per_page' => 6,
);
$query = new WP_Query($args);
if($query -> have_posts()):while($query -> have_posts()):$query -> the_post();
Upvotes: 1
Views: 771
Reputation: 713
Your arguments are incorrect.
Try this.
$args = array(
'post_type' => 'news',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'newscat',
'field' => 'slug',
'terms' => 'news'
),
),
);
$query = new WP_Query($args);
if($query -> have_posts()):while($query -> have_posts()):$query -> the_post();
Upvotes: 2