我正在尝试按meta\\u值(特色)然后按标题排序一些帖子。我把特色的按正确的顺序排列,但是,我在特色的后面混合了一些非特色的,我注意到这只发生在第一页。我做错什么了吗?我需要做什么才能在按字母顺序排列的通话中先获得特色和非特色?,这是我的问题(使用名为Vantage的高级主题):
function appthemes_addon_on_top_query( $wp_query ){
$addon_type = $wp_query->get( \'addon_on_top\' );
if( ! $addon_type || ! appthemes_addon_exists( $addon_type ) ) {
return;
}
$addon_info = appthemes_get_addon_info( $addon_type );
$flag_key = $addon_info[\'flag_key\']; // _listing-featured-cat
$meta_query = (array) $wp_query->get( \'meta_value\', 1 );
$meta_query = array_filter( $meta_query );
$meta_query[] = array(
\'relation\' => \'OR\',
array(
\'key\' => $flag_key,
\'compare\' => \'NOT EXISTS\',
),
array(
\'relation\' => \'OR\',
array(
\'key\' => $flag_key,
\'value\' => 1,
),
array(
\'key\' => $flag_key,
\'value\' => 1,
\'compare\' => \'!=\',
),
),
);
$wp_query->set( \'meta_query\', $meta_query );
/* Set an order by meta_value first and then by title */
$wp_query->set( \'orderby\', array( \'meta_value\' => \'DESC\', \'post_title\' => \'ASC\' ) );
/*echo "<pre>"; print_r($meta_query); echo "</pre>";*/
}
特色:
http://prntscr.com/kno3lk非特色:
http://prntscr.com/kno3vc