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?

  • Is the news category available to the articlespost type? – Tunji Jan 8 '17 at 13:21

The arguments for your query would be like:

$args = array(
    'post_type' => 'articles',               
    'tax_query' => array(
            'taxonomy' => 'category',
            'field'    => 'name',
            'terms'    => 'news',                                    

$loop = new WP_Query( $args );

if ( $loop->have_posts() ) :
    while ( $loop->have_posts() ) : $loop->the_post();  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.