I have a requirement where I need to show all posts having thumbnail first and ordered by title and then remaining posts ordered by title Below is the code I tried $the_page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : -1; $args = array( ‘post_type’ => “listings”, ‘post_status’ => ‘publish’, //’meta_key’ => ‘_thumbnail_id’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 88, ‘paged’ => $the_page, ‘orderby’ => ‘meta_key title’, ‘meta_query’ => array( //query post based on meta key array( ‘relation’ => ‘OR’, // add condition if meta key is exists or not array( ‘key’ => ‘_thumbnail_id’, ‘compare’ => ‘NOT EXISTS’ // include post without _thumbnail_id key ), array( ‘key’ => ‘_thumbnail_id’, ‘compare’ => ‘NOT NULL’ // include post without _thumbnail_id key ) ) ) If we look closely , I have set orderby=’meta_key title’ and meta_key is not one of supported arguments in WP_Query Documnentation hence its being removed by WP_Query while generating sql. In generated sql only ORDER BY wp_posts.post_title DESC is generated. My question is: 1. do we have any other way to get posts with thumbnail first in the list ? 2. do we have a way to order result by field that is not listed in WP_Query supported arguments list ? Any… Read full this story
- Live blog: Bucs return missed field goal 109 yards for TD
- Fred Couples to play in Grand Blanc; Ally Challenge field finalized
- Ford: CEO Alan Mulally Stays On Through At Least 2014, Mark Fields Promoted to COO
- All you need to know about this season's Champions Cup and why past glory may be key for Ulster
- Five Key Offseason Questions: New Orleans Pelicans
- VW emissions scandal: uncertainty over used values
- Offseason Keys: New Jersey Devils
- What Happened To Ford’s U.S. Market Share During The Mark Fields Era?
- Glenbard West's Ebl getting extra fielding practice -- with White Sox
- Week 3 NFL DFS Strategy: Picks, advice, values for DraftKings, FanDuel
Order by meta_key field in Wordpress not meta_value field value have 328 words, post on wordpress.stackexchange.com at August 23, 2019. This is cached page on Wordpress. If you want remove this page, please contact us.