【问题标题】:Wordpress built-in pagination not workingWordpress 内置分页不起作用
【发布时间】:2012-07-19 01:42:25
【问题描述】:

在 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(); ?>

谢谢!

【问题讨论】:

    标签: wordpress pagination


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-11-25
      • 2018-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多