如果我正确理解您的目标,我会创建两个queries. 第一个将只检索特色帖子。我们将仅在第一页显示该帖子,并存储其ID以供以后使用。然后,第二个查询将获得所有剩余的帖子。
// first query to retrieve the featured post
$featured_post_id = 0; // later we\'ll store the featured post\'s ID here
if(!is_paged()){ // ensure we only see the feature post on the first page
$first_args = array(
\'post_type\' => array(\'post\'), // change to custom post type if using one
\'post_status\' => array(\'publish\'), // only get the latest published post
\'posts_per_page\' => 1, // we\'ll only get one post
\'cat\' => 666, // put the ID of the \'featured\' category here
);
$first_query = new WP_Query( $first_args );
if($first_query->have_posts()) {
while($first_query->have_posts()) {
$first_query->the_post();
$featured_post_id = get_the_ID();
// your code for displaying the featured post here
}
} else {
return;
}
}
// second query to retrieve remaining posts (excluding featured post from above)
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
$second_args = array(
\'post_type\' => array(\'post\'),
\'post_status\' => array(\'publish\'),
\'posts_per_page\' => get_option( \'posts_per_page\' ), // will retrieve number of posts based on value set in Wordpress\'s admin > Settings > Reading
\'paged\' => $paged, // use pagination
\'post__not_in\' => array($featured_post_id), // exclude featured post from first query
);
$second_query = new WP_Query( $second_args );
if($second_query->have_posts()) {
while($second_query->have_posts()) {
$second_query->the_post();
// your code for displaying remaining posts here
}
} else {
return;
}
the_posts_pagination(); // your pagination code here