Make use of the WP_Query
class, namely the tax_query
and fields
parameters. Get the count from the $found_posts
property. Please note, this is exemplary code.
$query = new WP_Query( [
'post_type' => 'games',
'tax_query' = [
'relation' => 'AND',
[
'taxonomy' => 'game_status',
'field' => 'slug',
'terms' => [ 'beaten' ],
],
[
'taxonomy' => 'console',
'field' => 'slug',
'terms' => [ 'switch' ],
]
],
'fields' => 'ids',
] );
$count = $query->found_posts;
Related Posts:
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- Combining categories (Query posts with multiple taxonomy terms)
- How to get posts by category and by choosing a taxonomy term?
- get_the_terms has strange result since version 6.0
- Related categories order posts by category
- list all post who have mutual taxonomy as current taxonomy!
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- query_posts problem – need help
- WP_Query on custom taxonomy -> Location and Activity
- How to display an other custom post type in a different custom post type’s archive?
- Exclude Category filter from Portfolio section
- Search form not working with custom query?
- Post loop for all taxonomy terms
- Display custom tags on pages that have a specific page parent
- wp_query args adding muitiple tax_querys
- Query most popular terms by taxonomy over 2 week period
- Inserting HTML to close and open divs in WP_Query loops
- find posts that don’t have a custom taxonomy
- Limiting number of related posts
- WP the_posts() on single-cars.php get category link
- Category ‘pad_counts’ & ‘parent’ conflict
- Custom taxonomy.php not working
- Filter Custom Taxonomy Posts
- WP_Query args to show posts from specific custom taxonomy
- WP_Query for a taxonomy with different taxonomy types
- Finding WordPress Posts assigned to multiple categories
- Include posts from some categories while excluding from others
- get all posts associated with a custom taxonomy
- How to set an alternate posts_per_page value for default queries in different templates
- Combine results of multiple WP_Query to resemble single WP_Query
- Using custom taxonomies in a query
- Display posts of specific category term
- WordPress Custom Search Form Displaying Unexpected Results
- How to add custom meta to ‘pre_get_terms’?
- Tax Query only returns for the first of several terms
- Can’t fetch Custom Post Type Data through Custom Query
- get term id from term name
- WP_Query to output chosen term and posts with no term assigned
- wp_query is showing posts from other categories
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- WP_Query Taxonomy categories filtering
- Hide products in uncategorized category from search results
- One WP_Query that always shows 1 post from category X and 1 post from “not in category X”?
- How to load a script code only in posts?
- How to print term name inside wp post loop
- How to echo woocommerce category name
- Check if a post has term inside loop
- How to display a list of posts in same child category as current post
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- How to exclude a category name from showing?
- Loop categories by recent post
- How order posts from category by date and comment count?
- Get the child category ID of current category
- Related Posts Excluding Certain Categories
- Getting the permalink to the latest post from a category
- How to restrict search on a certain page to only return results against custom taxonomies?
- What is wrong with my WP_Query Arguments?
- Query Taxonomy By Page Title
- Custom Taxonomy Breaks Pages
- I need to exclude from a query a category and a few custom taxonomies
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- How to display posts from custom post type category(custom Taxonomy) wise?
- Post incorrectly excluded when using “category__in”?
- Related posts by current posts child category
- Filter sub-category from checkbox form
- wp-query and wp_get_post_terms on custom taxonomy archive page
- Why is my pagination /page/2 taking me to index.php?
- `offset` WP_Query argument dont work via `pre_get_posts`
- Use get_cat_ID to retreive multiple category IDs
- Function the_posts_pagination() not compatible with WP_Query arguments
- Filter products on category AND tag
- adding pagination to a foreach loop in wordpress
- Show X taxonomies of the latest published posts
- How do I compare the value of two taxonomies in a wp_query
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- display ACF repater field in archive page
- query hook parse_tax_query function takes no effect
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Filter for each loop when WP_Query has no posts to show
- How to use the Term Object from a custom select field in a query
- Custom Taxonomy – Modify Function to Get Child Category
- 3 posts from each existing category on one page
- WP Query by 4 different taxonomies
- How to display the category dropdown auto search list when key press?
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- Categories In English version showing not canonical URL, instead shows query search result
- How do I stop the same post showing multiple times in a archive?
- What code to use in an array to call the current sub-category?
- Get categories within specific term
- WordPress – Form does not filter the results of taxonomies
- How to show specify category template for both parent and child category
- WP Query for all events prior to current date
- How to get taxonomy image attached to a Post Type WordPress
- Pagination for Category does not work
- Exclude parent categories from recent posts list
- Display All Top Child Categories / Taxonomy
- Query post by Category and custom file (ACF)
- Show one post of each custom taxonomy
- Query WP Posts, then list the taxonomies from those posts