Try this:
$args = array(
'post_type' => 'post',
'meta_key' => 'pb_issue_featured',
'orderby' => 'meta_value',
'order' => 'DESC',
'posts_per_page' => $posts,
'paged' => $paged,
'paged' => 1,
'meta_query' => array(
array(
'key' => 'headline',
'value' => 1,
'compare' => '!='
)
)
);
add_filter( 'posts_orderby', 'filter_query' );
$q = new WP_Query($args);
remove_filter( 'posts_orderby', 'filter_query' );
function filter_query( $query ) {
$query .= ', wp_posts.menu_order ASC';
return $query;
}
Related Posts:
- Order by summing multiple values
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Return only Count from a wp_query request?
- Use REGEXP in WP_Query meta_query key
- 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
- WP_Query order by multiple meta keys & fields
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- 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)
- Get posts by menu ID
- How to order posts tag by tag?
- Slow SQL_CALC_FOUND_ROWS Query
- 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
- 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
- What’s wrong with this WP query?
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- How to count post meta key values for all posts in database
- 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
- Group posts by meta_key
- Revolution Slider Orderby Two Custom Fields
- How to search for posts IN OR title OR content OR author?
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- Order by the results of a function with WP_query
- Would this post meta be better added to the post table rather than post_meta table
- How to order posts in wp_query by a meta_value of the corresponding author
- Order By Multiple Meta Fields
- Order by menu structure
- meta_query on a date range using an array of values
- How to speed up wp_query, took more 5s to run against 100k posts
- WP_Query order by date in meta_value
- SQL User Query by Multiple Roles using PHP
- 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?
- WordPress Query is taking more then 20 second and stuck on creating index
- 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
- Get the Plugin Which Triggered a MySql Query in WordPress?
- 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
- Mysql query LIKE not working
- How to get posts on a specific date – WP Query
- How can I order Wp_Query hierarchically?
- Using WP_Query and WP_Meta_Query Outside of WordPress
- How do I sort posts with multiple pages
- Sorting posts DESC based on the number of comments using WP_Query
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Improve wp query perfomance on large db
- Order by custom table and multiplication
- 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
- Single meta_query query using OR instead of AND in request’s WHERE statement
- why update and delete query not worked in custom table?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Orderby ASC changes to DESC in WP_Query
- How to use MySQL’s MATCH AGAINST in WP_Query?
- 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
- Slow WP_Query for custom post type
- Performance when getting post meta for post retrieved by meta value
- Complex WP_Query order request: DESC by day, but then ASC by time
- Hide Administrators From User List except current user (administrator)
- How to set multiple `orderby` in query argument?
- WP_Query order result by date AND meta_value
- Add “Category” to Mysql Query
- Mysql query and order meta value
- Help with WP_Query – Too many mySQL queries
- Order by title without taking into account ‘the’
- Using hook to use DISTINCT in a wp_query
- WP_Query orderby author__in
- How to orderby multiple meta fields if some fields are empty
- pagination with ‘no_found_rows’ => true,
- 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
- Weird orderby => post__in issue
- Understanding the orderby in WP_Query?
- Order by empty custom field