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
- Exclude or Include category ids in WP_Query
- Show posts without term
- How to add taxonomy filter on the query fly?
- Combine two taxonomies in a hierarchical tree
- Query two taxonomies via URL or link?
- Use Transient API to cache queries for all posts in all categories?
- Select posts wich has no relationship in custom taxonomy
- How do I search WordPress by different fields without a plugin?
- List taxonomy terms plus their latest post ordered by post date
- Filter and list posts of a custom taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- How to select posts from one category but exclude posts in another category?
- Query Custom Post Type Order By Taxonomy Field
- Querying Term Posts in Loop
- Formulate a url to show posts with both taxonomy terms
- How can you get first post, last post and post count in a category?
- Query with custom taxonomy not working
- Function get_queried_object() return NULL in custom taxonomy
- List of the years with posts presented
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Query custom post type by custom taxonomy (category slug)
- How to Filter Posts by Custom Fields?
- Category applied to pages, creates multiple breadcrumb entries after a search query (On the translated site)
- Can we return all category (not post) with Custom Query Filter? [closed]
- wp_query for multiple cities (multiple values in a metabox)
- Query posts from category A, and from either category B or C
- Filtering out child category posts from parent category archive not working
- Exclude Category filter from Portfolio section
- Search form not working with custom query?
- Display custom tags on pages that have a specific page parent
- Query most popular terms by taxonomy over 2 week period
- Limiting number of related posts
- Category ‘pad_counts’ & ‘parent’ conflict
- Filter Custom Taxonomy Posts
- WP_Query args to show posts from specific custom taxonomy
- WP_Query for a taxonomy with different taxonomy types
- Include posts from some categories while excluding from others
- Using custom taxonomies in a query
- Display posts of specific category term
- get term id from term name
- WP_Query to output chosen term and posts with no term assigned
- Hide products in uncategorized category from search results
- How to echo woocommerce category name
- Slider won’t work with custom query
- WP_Query with one category in args shows other categories
- How order posts from category by date and comment count?
- Custom Taxonomy Breaks Pages
- Filter sub-category from checkbox form
- `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
- adding pagination to a foreach loop in wordpress
- Show X taxonomies of the latest published posts
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Custom Taxonomy – Modify Function to Get Child Category
- 3 posts from each existing category on one page
- 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
- Get categories within specific term
- How to show specify category template for both parent and child category
- Exclude parent categories from recent posts list
- Query WP Posts, then list the taxonomies from those posts
- Check the product in the cart from which category is and show message
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- Multiple values in WP_Query : category__and
- How to exclude posts by ID within a category/archive loop
- Optimal way to make tags in tax_query optional?
- I have 3 categories, i want to display on a loop the last 3 of every category
- Adding Category in WP_Query Not Working
- Taxonomy Terms That Don’t Exist Display Results
- Making Woocommerce optimized for more than 500k products
- Adding additional taxonomies to wordpress taxonomy page
- display all posts from category with and without terms in chronological order
- How to create page that lists tags by initial letter?
- Pull posts from all categories if quantity is not met?
- Category Archive not working for pages
- How can I get all the posts that are related with a specific taxonomy term?
- How to combine nested tax_query logic with other nested query logic?
- Query Top Set Custom Taxonomy In Given Timeperiod
- Custom taxonomy and query multi conditions
- Retrieving category pages from subcategory returns empty sets
- Rewrite rule pagination on different url levels
- Select posts wich has no relationship in custom taxonomy
- How to get hierarchical number of custom taxanomy
- Get newest value of an array
- Display Count of posts
- Filter custom post type by custom taxomony
- Custom query to order by multiple taxonomies
- WP_Query and DES sort for Custom Taxonomy based upon a meta field?
- tax_query not working properly with get_posts
- I need to get all categories from a WP_Query
- Excluding a category from frontpage but not from WP_Query