【发布时间】:2018-10-14 07:29:34
【问题描述】:
我正在尝试列出“阿尔卑斯山”类别中的帖子。问题是,如果我定义 'posts_per_page'=> -1,效果很好,我会得到完整的列表,但如果我要求一些帖子,我只会得到相同的帖子,一页又一页地重复。这是我的 loop-alps.php 文件。
<?php
$args = array(
'order' => 'asc',
'order_by' => 'title',
'posts_per_page'=> 5,
'category_name'=> 'alps'
);
$wp_query = new WP_Query($args);
if($wp_query->have_posts()): while($wp_query->have_posts()): $wp_query->the_post();
echo '<h1>' .get_the_title() .'</h1>';
the_post_thumbnail();
endwhile;
endif;
?>
<div class="navigation">
<?php if(function_exists('tw_pagination')) tw_pagination($the_query); ?>
</div>
【问题讨论】:
-
我相信您需要使用更多参数:codex.wordpress.org/Class_Reference/…
标签: php loops pagination wordpress