我尝试在我的类别上添加分页系统。php页面。
它适用于第一个页面:例如url/category/cat1/。大量的帖子被显示出来,我只有在需要的时候才得到一个“阅读更多”的链接。。。
但对于第二个页面:例如url/category/cat1/page/2/。它不会从类别加载代码。php,但来自索引。php!
我错过了什么?
类别中的代码。php:
<?php
get_header();
$categories = get_the_category();
if ( ! empty( $categories ) )
{
$category = $categories[0]->name;
}
$paged = ( get_query_var( \'paged\' ) ) ? absint( get_query_var( \'paged\' ) ) : 1;
query_posts( \'category_name=\'.$category.\'&posts_per_page=1&paged=\'.$paged );
while (have_posts()) :
the_post();
the_title();
the_excerpt();
echo\'<a href="\'.get_permalink().\'"> Read more...</a>\';
endwhile;
?>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link(\'« Previous Entries\') ?></div>
<div class="alignright"><?php next_posts_link(\'Next Entries »\',\'\') ?></div>
</div>
<?php
get_footer();
?>