我会做一个每页12篇文章的循环,打印4篇文章后,我会调用另一个6篇自定义文章的循环。然后返回并打印当前页面的最后8篇帖子。
<?php
$index = 1;
$paged = ( get_query_var(\'paged\') ) ? get_query_var(\'paged\') : 1;
$posts = new WP_Query(array(\'post_type\' => \'post\', \'posts_per_page\' => 12, \'paged\' => $paged));
if ($posts->have_posts()) : while ($posts->have_posts()) : $posts->the_post(); ?>
<article>
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?></p>
</article>
<?php
if($index == 4){
$custom = new WP_Query(array(\'post_type\' => \'CUSTOM-POST-TYPE\', \'posts_per_page\' => 6));
if ($pcustom->have_posts()) : while ($pcustom->have_posts()) : $pcustom->the_post(); ?>
<article>
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?></p>
</article>
<?php
endwhile; endif;
}
$index++;
endwhile; endif;
wp_pagenavi($posts);
?>