我已经在网上阅读了一些关于他的问题的信息,但我没有认真的解决方案。我阅读的资源: http:
//codex.wordpress.org/The_Loop#Multiple_Loops_in_Action
现在这是我在 index.php 中的代码:
<!--slider-->
<div id="featured">
<?php
// query the posts of your custom post types
query_posts('posts_per_page=5');
if (have_posts()) : while (have_posts()) : the_post(); ?>
<!--main body-->
<?php
// query the posts of your custom post types
query_posts('posts_per_page=5&offset=5');
if (have_posts()) : while (have_posts()) : the_post(); ?>
当我按下下一个帖子时,我会得到相同的正文帖子副本。
解决方案是什么?
编辑: 我写了新代码:
// featured
$slider = new WP_Query(array('posts_per_page' => 5));
if ($slider->have_posts()) : while ($slider->have_posts()) : $slider->the_post();
//main:
$p = get_query_var('paged');
if($p >0){
$main = new WP_Query(array('posts_per_page' => 5, 'paged'=>get_query_var('paged')));
}else{
$main = new WP_Query(array('posts_per_page' => 5, 'offset' => 5,'paged'=>get_query_var('paged')));
}
if ($main->have_posts()) : while ($main->have_posts()) : $main->the_post();
//导航:
<div class="navigation" >
<div class="next-posts"><div class="nextBtn2"><?php previous_posts_link(); ?></div></div>
<div class="prev-posts"><?php next_posts_link(); ?></div>
</div>