You can filter the orderby
part of the query to get what you want (trying to pass it via the orderby
parameter will not work, it will be filtered out). This simple example adds the meta_value
sort order before the standard title sort order.
add_filter( 'posts_orderby', 'wpse15168_posts_orderby' );
$query = new WP_Query( array(
'meta_key' => 'interesting',
'orderby' => 'title',
'order' => 'ASC',
) );
remove_filter( 'posts_orderby', 'wpse15168_posts_orderby' );
function wpse15168_posts_orderby( $orderby )
{
global $wpdb;
$orderby = $wpdb->postmeta . '.meta_value DESC, ' . $orderby;
return $orderby;
}
Related Posts:
- Exclude taxonomy term from all loops, but having it on widget
- Using wp_query is it possible to orderby taxonomy?
- “tax_query” parameter not working with WP_Query
- How do I exclude a custom taxonomy from the post loop
- Retrieve posts by term id custom query
- Display category posts grouped by taxonomy
- Custom Taxonomy and Tax_Query
- Using WordPress to make a “Product Search” type navigation drilldown
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- display posts with same taxonomy term
- restrict_manage_posts not working in 3.3.1
- Including all terms in wordpress tax_query
- How to get first post in a category of a custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- search query within custom taxonomy term, post title and meta field
- Filter all queries with a specific taxonomy
- wp query with multiple taxonomy?
- On Taxonomy Template page, want to add Post_Type
- Page queried instead of a custom taxonomy
- Querying Posts by Taxonomy From Alternate Network Site
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!
- The next_posts_link() show me a aditional page in blank
- Help with a query not working with custom taxonomy
- Adding session variable and/or cookie based on user-selected input
- Excluding a custom taxonomy term breaks wp_get_post_terms
- Advanced Tax Query
- why do drafts return as part of wp_query?
- Improving WP_Query performance for multiple taxonomies
- Taxonomy.php issue with search and filters
- How to List Parent Term Links for Custom Taxonomy With & Without Children?
- WP Query with custom taxonomy
- how to search in custom fields & custom taxonomy for custom search
- WP_Query search posts by custom post type and custom taxonomy
- How to do a query on custom taxonomies that is uncategorised?
- Recreating the hierarchy of taxonomies for a dropdown form menu?
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Querying Term Posts in Loop
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- Custom taxonomy query not working with switch_to_blog
- Advanced Query Logic With Multiple Taxonomies
- How do I Use Multiple Loops with WP_Query?
- $wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?
- cannot get multiple loops using tax_query
- Print terms with taxonomy and metabox value
- Query custom post type by custom taxonomy (category slug)
- Search / Filter posts on Title/Content OR Tags
- Display all posts for taxonomy term across multiple custom post types
- Selecting all posts from the children of a particular parent taxonomy
- Checkbox onclick filtering on the same page
- A way to query custom taxonomies by name
- get the taxonomies terms associated with users
- Query with relation and one without relation using multiple taxonomies?
- First custom field value (out of several) displayed twice after query
- WP_Query orderby and tax_query
- Hiding taxonomies with no children WP_Query & tax_query
- Rewrite Rules returning wrong data
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- Sorting main query by custom taxonomy slug
- WordPress Custom post query sorting does not work
- List related terms + taxonomies
- Set tax_query conditionally with new WP_Query
- querying posts by custom taxonomy terms right from a querystring based URL
- Search Query for Multiple Terms In Same Taxonomy
- Query custom taxonomy by term id?
- WP_Query() with custom post type and taxonomy — get all terms?
- When filtering query on custom taxonomy; main menu dissapears
- Why can’t I use an array of term slugs in WP_Query?
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- Problem with wordpress pagination
- How to do a particular wp_query taxonomy search
- How to add custom meta to ‘pre_get_terms’?
- Get list of taxonomies associated with users
- query_posts that have custom taxonomy and limiting what shows based on the taxonomy
- Several taxonomy query (like filter)
- Wp_query…a type of term a different div
- Taxonomy archive template that shows posts from more than one taxonomy
- check if a taxnomy queried in $wp_query?
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- WP_Query tax_query – Show results if child has parent X
- how to access the $query variable inside taxonomy-xxx.php template file?
- Query custom taxonomy for category including children
- Displaying Posts Attached to Custom Taxonomy Terms
- Update Custom Taxonomy Value for a post based on custom date field
- Proper way to create taxonomy queries
- how to use tax_query to apply both terms or one if one is empty
- Get current page term title to use in WP_Query
- passing moree than one value of slugs in taxonomy using variable
- Query custom posts from custom taxonomy
- Get 1st parent category id from post
- How to get the term description in a taxonomy term archive query?
- making an index from custom taxonomies and tags of posts (not hierarchical taxonomy)
- Query Multiple Custom Taxonomies
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Query by multiple custom taxonomies
- My entry results are not consistently alphabetized
- WP Query : strange behaviour with multiple no-hierarchical tax
- WordPress search form and search result through ACF field in custom taxonomy