Wordpress内置分页无法正常工作

时间:2012-07-17 19:55:51

标签: wordpress pagination

在Wordpress阅读选项中,我将其设置为索引最多只显示2个帖子。但是,缺少下一页和上一页页按钮。我进入了我的模板,尝试了默认方法,但没有一个工作。

我尝试添加

<?php posts_nav_link(); ?>

没用。然后我尝试了

<div class="navigation">
  <div class="alignleft"><?php next_posts_link('« Previous Entries') ?></div>
  <div class="alignright"><?php previous_posts_link('Next Entries »') ?></div>
</div>

哪个也行不通。根本没有出现在最终页面的源代码中。这些是默认的Wordpress功能,对吧?这里出了什么问题?

如果它有用,这里是index.php

<?php get_header(); ?>

<section class="content">
    <ul class="items wrap">
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h1><?php the_title(); ?></h1>
        <h4><?php the_time('F jS, Y') ?></h4>
        <p><?php the_content(__('(more...)')); ?></p>
        <hr>
        <?php endwhile; else: ?>
        <p><?php _e('Sorry, we couldn’t find the post you are looking for.'); ?></p>
        <?php endif; ?>
        <!-- I added the pagination code here. -->
    </ul>
</section>

<div id="delimiter"></div>

<?php get_footer(); ?>

谢谢!

1 个答案:

答案 0 :(得分:0)

原来只有两个帖子要显示,所以当然没有显示下一个/上一个链接。所以问题就解决了。

相关问题