Wordpress category and tag query

Asked

Viewed 57 times

0

How I search posts by category and tag? I did it and it didn’t work:

query_posts(array( 
    'post_type' => 'noticias',
    'showposts' => 2,
    'category__and' => array(70),
    'tag__in'   => array(77),
) );

1 answer

0

If I got it right, you’re looking to pick up all the category-specific posts from a Custom Post Type, right? category__and is used for the default wordpress post category. In CPT for you to group post by categories vc uses taxonomy and to query use the parameter 'tax_query'.

Try it this way:

query_posts(array( 'post_type' => 'noticias',
   'posts_per_page' => 2,
   'tax_query' => array( array(
   'taxonomy' => 'ID_DA_TAXYNOMIA', 
   'field' => 'term_id', 
   'terms' => array( 70 ) ))));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.