• Hi,
    I have two post_type
    1. post (default)
    2. coupon

    Taxonomies (category) for post: first_cate, second_cate, third_cate
    Taxonomies (coupon_category) for coupon: type_a,type_b,type_c

    Now I have two question
    1. I want to select “posts” (post_type=’post’) from only two categories (first_cate, second_cate) but show all coupons (post_type=’coupon’) from coupon_category

    2. I want to select “posts” (post_type=’post’) from only two categories (first_cate, second_cate) and show selected coupons (post_type=’coupon’) from two categories “type_a”, “type_c”

    (Note: taxonomy for coupons is ‘coupon_category’)

Viewing 1 replies (of 1 total)
  • I can’t test this, but queries like this should be close to what you want:

    $args = array(
       'ignore_sticky_posts' => 1,
       'posts_per_page' => -1,
       'post_type' => array('post','coupon'),
       'tax_query' => array(
          'relation' => 'OR',
          array(
             'taxonomy' => 'category',
             'field' => 'slug',
             'terms' => array('first_cate', 'second_cate'),
             'include_children' => false,
             'operator' => 'IN'
          ),
          array(
             'taxonomy' => 'coupon_category',
             'field' => 'slug',
             'terms' => array('type_a', 'type_b', 'type_c'),
             'operator' => 'IN'
          )
       )
    );
    query_posts($args);
Viewing 1 replies (of 1 total)
  • The topic ‘HELP! wp query SELECT multiple post_type with multiple taxonomies’ is closed to new replies.