this topic might help you. By default args of WP_Query – this is impossible.
I don’t think you can do that directly. Although you can save terms
count for each post in a custom meta field (on post publish) and then
in your query define sort by that meta field. Or while running your
query, you can save terms count along with posts ids in another array,
then sort them by count and print posts. Second one will consume more
resources so I would recommend first method.SELECT p.ID,COUNT(*) count FROM wp_term_relationships r, wp_posts p,
wp_term_taxonomy x WHERE r.object_id = p.ID AND p.post_type=”post”
AND r.term_taxonomy_id = x.term_taxonomy_id AND x.taxonomy =
‘post_tag’ GROUP BY object_id ORDER BY count;you can’t do it directly, you need a filter and a CASE in the orderby eg
Related Posts:
- WordPress tax_query “and” operator not functioning as desired
- Custom taxonomy query broken after upgrade to 4.4
- Show posts without term
- How to add taxonomy filter on the query fly?
- Query two taxonomies via URL or link?
- Counting number of posts with Category B in Category A
- Select posts wich has no relationship in custom taxonomy
- List taxonomy terms plus their latest post ordered by post date
- Filter and list posts of a custom taxonomy
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- How to Modify Taxonomy Archive Page with Search Parameter?
- Get array of current post term ID’s
- Setup of taxonomy term template pages
- Display link to taxonomy archive only if it has posts with certain custom field values
- How to do a query on custom taxonomies that is uncategorised?
- WP_Query, tax_query and term_meta: How to?
- Order taxonomy terms in alphabetical order
- Query Custom Post Type Order By Taxonomy Field
- Query with custom taxonomy not working
- Function get_queried_object() return NULL in custom taxonomy
- Getting Taxonomy inside WP_Query Loop
- showing all search result in one template
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Query custom post type by custom taxonomy (category slug)
- How to Filter Posts by Custom Fields?
- Show posts from a custom taxonomy on a page
- WP_Query ignoring tax_query when is_singular
- How do I exclude the lowest level terms in a taxonomy?
- wp_query for multiple cities (multiple values in a metabox)
- Query with relation and one without relation using multiple taxonomies?
- 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
- find posts that don’t have a custom taxonomy
- 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
- get all posts associated with a custom taxonomy
- How to set an alternate posts_per_page value for default queries in different templates
- Using custom taxonomies in a query
- 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
- WP_Query to output chosen term and posts with no term assigned
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- One WP_Query that always shows 1 post from category X and 1 post from “not in category X”?
- How to print term name inside wp post loop
- Check if a post has term inside loop
- How to get posts by category and by choosing a taxonomy term?
- How to restrict search on a certain page to only return results against custom taxonomies?
- Query Taxonomy By Page Title
- Custom Taxonomy Breaks Pages
- get_the_terms has strange result since version 6.0
- How to display posts from custom post type category(custom Taxonomy) wise?
- wp-query and wp_get_post_terms on custom taxonomy archive page
- Why is my pagination /page/2 taking me to index.php?
- display ACF repater field in archive page
- Filter for each loop when WP_Query has no posts to show
- Custom Taxonomy – Modify Function to Get Child Category
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- How do I stop the same post showing multiple times in a archive?
- Related categories order posts by category
- WordPress – Form does not filter the results of taxonomies
- WP Query for all events prior to current date
- How to get taxonomy image attached to a Post Type WordPress
- list all post who have mutual taxonomy as current taxonomy!
- Show one post of each custom taxonomy
- Displaying posts from sub taxonomies only
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- How to define a custom hierarchy for terms?
- My entry results are not consistently alphabetized
- Adding additional taxonomies to wordpress taxonomy page
- I cannot get tax_query in get_posts() to work with custom taxonomy
- 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
- tax_query not working for taxonomy slug
- Select posts wich has no relationship in custom taxonomy
- Custom query for tag and custom tag from 2 post type
- How to get hierarchical number of custom taxanomy
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- WP_Query to show post from a category OR custom field – Not 100% answered
- Get newest value of an array
- Filter custom post type by custom taxomony
- Hiding all posts/products/pages from a site based on a custom taxonomy/domain name
- Page displaying 1st post from a range of custom tax?
- WordPress WP_Query Array Custom search via taxonomies
- query_posts problem – need help
- Give attachments an archive page, and exclude unattached ones
- Custom Taxonomy in custom REST API search
- I’m trying to get posts under a custom taxonomy but I don’t know what I’m doing wrong here
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Adding a language rule and displaying posts with a custom taxonomy term on its archive page
- WP_Query on custom taxonomy -> Location and Activity
- Filter on one post type with taxonimy and get other post type
- Include custom post type that matches taxonomy field in another custom post type
- Showing all posts of the current custom taxonomy on archive page