您可以使用per_get_posts
筛选器挂钩可更改查询的顺序,例如:
add_filter(\'pre_get_posts\', \'filter_homepage_posts_order\');
function filter_homepage_posts_order($query) {
//only run is current page is home page
if ($query->is_home) {
$limit_number_of_posts = 5; //number of posts
$featured_category_id = get_cat_id(\'Reviews\'); // by cat name...
$query->set(\'cat\', $featured_category_id);
$query->set(\'posts_per_page\', $limit_number_of_posts);
$query->set(\'order\',\'DESC\')
}
return $query;
}