I have a custom post type called articles
and have category = news
I want to make a query from the two parts to get content from (cpt=articles, category=news) in the same query?
How can I achieve this?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI have a custom post type called articles
and have category = news
I want to make a query from the two parts to get content from (cpt=articles, category=news) in the same query?
How can I achieve this?
The arguments for your query would be like:
$args = array(
'post_type' => 'articles',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'name',
'terms' => 'news',
),
),
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
endwhile;
endif;
articles
post type?