WP_query taxonomy + get all posts with two terms from same taxonomy

You don’t need to 2 array for tax query. You can try this scenario:

$args2 = array('post_type' => 'custom',
               'tax_query' => array( 
                                array( 'taxonomy' => 'events', 
                                        'field' => 'slug',
                                        'terms' => array( 'tag1', 'tag-2')
                                      )
                                    )
                );
$query = new WP_Query($args);
echo $query->post_count;

You can see the Codex for better understanding.

Leave a Comment