为post\\u per\\u page=2运行一个wp\\u查询,并获取数组中这2篇文章的ID,以便在接下来需要的3篇文章中排除
<?php
// The Query
$next_args = array(
\'post_type\' => \'<your_post_type>\',
\'post_status\' => \'publish\',
\'posts_per_page\'=>2,
\'order\'=>\'DESC\',
\'orderby\'=>\'ID\',
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
$not_in_next_three = array();
while ( $the_query->have_posts() ) {
$the_query->the_post();
//your html here for latest 2
$not_in_next_three[] = get_the_ID();
}
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
现在,在获取接下来3篇文章的wp\\u查询中排除上面创建的数组
// The Query
$next_args = array(
\'post_type\' => \'<your_post_type>\',
\'post_status\' => \'publish\',
\'posts_per_page\'=>3,
\'order\'=>\'DESC\',
\'orderby\'=>\'ID\',
\'post__not_in\'=>$not_in_next_three
);
$next_the_query = new WP_Query( $next_args );
// The Loop
if ( $next_the_query->have_posts() ) {
while ( $next_the_query->have_posts() ) {
$next_the_query->the_post();
//your html here fir latest next 3
}
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
?>