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
- 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
- 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?
- 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
- Custom taxonomy query not working with switch_to_blog
- 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
- Rewrite Rules returning wrong data
- 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?
- Why can’t I use an array of term slugs in WP_Query?
- wp_query not resetting, last post hanging
- Problem with wordpress pagination
- 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
- WP_Query tax_query – Show results if child has parent X
- Query custom taxonomy for category including children
- Displaying Posts Attached to Custom Taxonomy Terms
- 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
- 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
- WP Query : strange behaviour with multiple no-hierarchical tax
- WordPress search form and search result through ACF field in custom taxonomy
- How can I get all the posts that are related with a specific taxonomy term?
- Get posts of an specific term of a custom taxonomy
- Query pages by child term
- Can I use multi (sub) levels of relation (AND | OR) on custom query?
- Tax Query not working
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- Custom taxonomy – query returns an error
- Run next query based on first query’s term
- Get the original menu item name string instead of the label
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Getting grandchildren of a post with a specified custom taxonomy?
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- Adding a query var to taxonomy term archive – gets redirected to the other taxonomy archive page
- Custom Taxonomy + JQuery Tabs
- Advanced AND tax_query in sidebar with 2 taxonomies
- How to query posts that are not related to any term of a taxonomy?
- Using wp_query is it possible to orderby taxonomy?
- How to limit posts to 1 from each term with tax_query?
- Can I use $query->set() (in a pre_get_posts() hook) with a custom taxonomy in WP 3?
- query grandchildren taxonomy terms