我一直在努力创建一个自定义循环,并设置每个页面的文章数量。我需要将这个循环与每个页面的博客文章分开--因此产生了自定义循环。
现在循环确实工作了,但是我注意到它与分页冲突.分页显示,但当您单击“下一步”时,页面不会更改。
这是我的循环:
<?php
$args = array('posts_per_page'=>12, 'post_type' =>'office');
$category_posts = new WP_Query($args);
if($category_posts->have_posts()) :
while($category_posts->have_posts()) :
$category_posts->the_post();
?>
<div class="office-item-wrapper">
<div class="office-item">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
</article>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article><!--/ Article -->
<?php endif; ?>预先感谢任何能帮我解决这个问题的人:-)
发布于 2015-08-29 14:16:53
在WP中,分页由GET变量在page下发送,只需将其添加到查询args:
$page = get_query_var('paged');
$args = array('posts_per_page'=>12, 'post_type' =>'office', 'paged'=>$page); 我建议您使用get_query_var('paged'),因为如果它是空的,它将发送到第一页。
注意:在某些主题中,页面编号是在page键中发送的,所以尝试使用page或paged__。
https://stackoverflow.com/questions/32286870
复制相似问题