我找到了重新排序已选定帖子的方法。
例如,我们选择了以下帖子:
$qargs = array(
\'posts_per_page\' => 15,
\'no_found_rows\' => true,
\'order\' => \'DESC\',
\'post_type\' => \'post\',
\'suppress_filters\' => false,
\'orderby\' => \'post_views\', // here I order my posts by views
\'fields\' => \'\',
\'date_query\' => array(
array(
\'after\' => \'-7 days\',
\'column\' => \'post_date\',
),
),
$posts_query = new WP_Query( $qargs );
现在我们可以按日期重新排列这些帖子:
function order_by_date( $a, $b ) {
return strcasecmp( $b->post_date, $a->post_date );
}
usort( $posts_query->posts, \'order_by_date\' );
接下来,我们可以回应我们的帖子:
if ( $posts_query->have_posts() ): ?>
while ( $posts_query->have_posts() ):
$posts_query->the_post();
.......