我正在使用一个混合了元字段和数据作为顺序参数的解决方案。
$query = new WP_Query( array(
\'post_type\' => \'post\',
\'meta_key\' => \'[your vote field]\',
\'orderby\' => \'date meta_value_num\',
\'order\' => \'DESC\',
\'meta_query\' => array(
array(
\'key\' => \'[your vote field]\',
\'value\' => [what values],
\'compare\' => \'[IN - NOT IN, you decide]\',
)
),
\'date_query\' => array(
\'after\' => \'1 day ago\',
)
));
然后还必须将其添加到函数中。php:
function wpse159469_posts_orderby( $orderby, $query ) {
return implode( \' DESC,\', explode( \',\', str_replace( array(\' ASC\', \' DESC\' ), \'\', $orderby ) ) ) . \' DESC\';
}
并记住在查询前后添加筛选器:
add_filter( \'posts_orderby\', \'wpse159469_posts_orderby\', 10, 2 );
//query and stuff
remove_filter( \'posts_orderby\', \'wpse159469_posts_orderby\', 10, 2 );
这个解决方案适合我。