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]
- Sorting: custom query with orderby meta_value_num THEN by title
- 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?
- WP_Query sort by comment meta data
- Searching user meta using WP_User_Query
- Order posts by tags count?
- Orderby = none not working [duplicate]
- 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
- 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
- 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
- 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
- Minimize database queries to user tables?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- Complex WP_Query order request: DESC by day, but then ASC by time
- How to set multiple `orderby` in query argument?
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- Order by empty custom field
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- Debugging wp_query orderby for taxonomy
- Ordering posts by an array
- How to Create a Random List of Child Pages
- Advanced WP_Query with meta_query, orderby?
- How to Order a list of taxonomies? orderby?
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- query post by author gender
- Child pages not affected by orderby
- Filtering by multiple conditions in the loop
- WP_User_Query orderby meta_val_num
- Sorting posts by Multiple custom fields in defined order
- Randomly select one of last 3 posts
- WP_Query orderby random do not repeat infinite scroll – one loop
- how to retrieve WP_Query without ordering by date [duplicate]
- orderby ignored by wp_query
- Sort posts using multiple custom fields and menu_order in single query?
- WP_Query orderby
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- How can I order a post query’s results based on the number of matching taxonomy terms?
- How to sort store location by specific category order in WP store locations
- Counting instances of words in the results of a post query
- How to sort wordpress posts already selected by WP_QUERY
- Custom WP Query order function possible?
- WP_Query random ordering not working since 5.4
- Meta query orderby meta_value_num sorting by role first
- Order by value of Custom Field using url string
- Order posts by tags count?
- Order by meta date with a thousanth of a second defaults to post order
- WP Query with meta queries
- Order Element By Custom Field in WordPress
- Sorting with meta_query and multiple, optional meta keys
- WP Query. Ordering posts by another post types meta
- WP_User_Query not searching numbers?
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- Display three sequential posts on each page load, without repeating previous
- Best way to Order Post in Home without a plugin
- orderby in WP_QUERY – Use the order from the Dashboard
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- 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
- query_posts with sorting on a custom datestamp
- Get post closest to today
- Order by multiple meta keys on wordpress
- Posts2Posts, wp_query and orderby issue
- WP_Query with several meta_query-statements and order by meta_value
- Change posts archive ordering
- 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