I don’t think this can be cleanly expressed in WP query API. YOu can query for posts matching all of terms in a set or any of terms in a set, but there is no concept of how many terms matched.
You would need to write either:
- Very custom SQL for the query you want which will implement the counting.
- Query loosely everything that matches and do the coun on PHP side after getting results.
Related Posts:
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_Query orderby date not working
- Order by optional meta key?
- Sorting: custom query with orderby meta_value_num THEN by title
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- Secondary Sort (fallback) for WP_Query
- Query Posts in a Predefined Order
- How to get order of posts?
- Order posts by ID in the given order
- Custom WP_Query order by post_meta and (author) user_meta
- Sorting posts by custom date fields (non standard date format)
- Getting all user metadata from user
- How to order posts tag by tag?
- How do I order pages and categories by ID or name in the same query?
- WP_Query ordered by custom field that is a date string?
- WP_Query sort by comment meta data
- Searching user meta using WP_User_Query
- Order posts by tags count?
- Merge 2 args in one WP_Query and order it by date
- Orderby = none not working [duplicate]
- SQL query equivalent to WP User Query
- WP_query ‘orderby=none’ Problem
- Order posts by date and then by custom field
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Revolution Slider Orderby Two Custom Fields
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- Order by the results of a function with WP_query
- How to order posts in wp_query by a meta_value of the corresponding author
- Order by menu structure
- WP_Query order by date in meta_value
- Query wp_usermeta alongside wp_users
- How to use order RAND() on WordPress?
- Show all parents and children in custom post type in right order
- Ordering by meta_value AND date NOT WORKING with wp_query
- WP_Query orderby breaks when using AJAX?
- Order WP Query posts by custom order calculated from post meta values
- Custom Post order for homepage
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- WordPress WP_Query orderby being overwritten
- WP_Query Order by Specific Post ID First
- Order Posts by meta value AND published date
- How can I pick a single post from the latest 3?
- Wp query orderby ‘title’ doesn’t work
- How can I order Wp_Query hierarchically?
- How do I sort posts with multiple pages
- Sorting posts DESC based on the number of comments using WP_Query
- Order WP_Query by multiple fields, subtracting them from one another
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- Minimize database queries to user tables?
- WP_Query: custom orderby (not ASC nor DESC)
- WP_User_Query not searching numbers?
- Order & Orderby clause not working with custom query
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- wp_query sorting – one specific meta_key value at last and then sort by create date
- query_posts based on a meta_key
- Display three sequential posts on each page load, without repeating previous
- Order posts by more than one variable (meta_key and publish date AND time)
- Create custom order sortby based on array of id
- Best way to Order Post in Home without a plugin
- orderby in WP_QUERY – Use the order from the Dashboard
- Sort by meta key within same day
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- Query All Attachments and Order by Parent Publish Date
- Order Custom Field by Price
- WP_Query within save_post doesn’t include the item that triggered the action?
- Using orderby with 2 meta keys
- Order posts by custom column using pre_get_posts
- Add filter to Orderby Parameter using Array
- Order WP_Query results in order other than ASC or DESC
- Show sticky post before other WP_Query
- Custom query to order by multiple taxonomies
- Sorting: custom query with orderby meta_value_num THEN by title
- query_posts with sorting on a custom datestamp
- Get post closest to today
- Order by multiple meta keys on wordpress
- orderby in WP_query doesn’t works
- Posts2Posts, wp_query and orderby issue
- WP_Query with several meta_query-statements and order by meta_value
- How ‘secure’ are loops?
- Order by meta values
- Change posts archive ordering
- orderby and order filter in get_posts or WP_query function in wordpress not working
- Get all user with both meta_value
- Get posts that were most recently tagged
- Why does wp_query only display the most recent post when using order ASC?
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- WP_Query sort by ACF date field (newest first) with blank dates first
- new WP_Query with order args – no more distinction between categories
- Orderby meta _value that is saved as an array
- Group users by meta field, with name of meta field as group title
- Sort wp_query of two post types using meta datefield for one and date for the other – possible?
- Conditionaly move certain posts at the bottom of the query result
- WordPress WP_Query custom order_by post_type functionality
- How do I group results from wp-query
- Custom tag template to list posts in ASC order