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.
Related Posts:
- SQL Statement generated by WP_Query not producing expected results
- Custom archive page based on array of categories and tags
- tax_query shows no results if nothing is selected
- get complex results set according to category structure
- Get image of latest post from taxonomies/categories
- Query Custom Post Type Order By Taxonomy Field
- Shortcode to show thumbnail and link for 3 random posts
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Combining categories (Query posts with multiple taxonomy terms)
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Automatically Query Parent Taxonomy
- Query most popular terms by taxonomy over 2 week period
- Custom taxonomy.php not working
- get all posts associated with a custom taxonomy
- Tax_Query using WP_Query not working
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- wp_query with meta_query and tax_query
- list all post who have mutual taxonomy as current taxonomy!
- Why pagination is not working with tax_query param?
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- Combine Tax Archive and Meta_Query in WP_Query
- Taxonomy Terms That Don’t Exist Display Results
- In Product Category archives how to show Posts having same/similar prod_cat slug structure?
- Object of class WP_Query could not be converted to int inside shortcode
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- List posts of terms but exclude one term
- WP_Query on “property” in the options table
- Query posts filter not working
- Output ACF field dynamicaly within a taxonomy loop [closed]
- Incorrect taxonomy ID assigned to post with custom query
- Exclude a category if post is only in that category using wp_Query
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Query certain amount of posts from multiple dates
- How to get post from all Blog Multisite to the Main Site?
- Sort in WP_Query(), not filter? Is it possible?
- Better to make new wp_query or only modify main query each time?
- Using WP Query to search within ALL keys in meta query
- Search product by brand name in wp_query
- What is the difference in a query when using a fieldname as a meta key vs orderby field?
- Get all post IDs from current WP_Query – not just currently visible
- WP User Query multiple AND OR query problem
- $wpdb->insert inserting two rows in database
- More than 1 Year Date Query
- Is it possible to dynamically get queried term AND taxonomy?
- posts_per_page not working
- WP Query for variable taxonomies
- WP_query Date Range results not matching loop
- Pull post meta with post_query?
- How to use WP_Query to display many posts?
- Complex WP_Query (two post types and multiple operators)
- Five posts from a category in footer
- Return only post(s) which have post_excerpt
- Front page with registered query params in URL shows blog archive instead of front page
- Order by empty custom field
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- Help ordering Post loop by two meta values
- New WP_Query loop in admin causes problems
- How to sort a custom wordpress query by combination of meta values?
- How to pass orderby params to $wpdb->prepare()?
- Get author if post has multiple authors
- What happens to the default query when I use WP_Query?
- Modifing archive query affects show post count function
- For what queries is conditional tags informative?
- posts archive page – closing WP_Query loop correctly [closed]
- JSON – Create rest api endpoint for Advanced Custom Fields
- Is it possible (and how to) query single Gutenberg blocks?
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Nested array issue in meta_query
- Query by key or author
- Why doesn’t my WP Meta Query return any results?
- How to build the WP_Query using the code?
- How go give $value to wp_query
- Show multiple tax_query from 2 or more post_type in a single code
- How to make the ‘request’ filter work?
- How to use rewind_comments() – when and how to use it?
- Related categories order posts by category
- Finding post ID dynamically on click
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Order Element By Custom Field in WordPress
- Display All Top Child Categories / Taxonomy
- how to get custom attachment url?
- ACF Post Object meta-query by title not ID
- Case insensitive ORDERBY in wpquery
- Sorting with meta_query and multiple, optional meta keys
- getting posts by tags
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- Calculating efficiently on large amount of data generated by wp_query
- Include post_status check within $wpdb query
- Return on a quest all these meta_value
- Complicated WP_Query
- Custom query to show posts
- New WordPress WP Query using posts from certain categories
- Taxonomy related query not working
- Multiple Orderby is not working right
- How to efficiently find “duplicate” posts, where the titles are different, using metadata to match posts?