【问题标题】:Wordpress Pagination not appearingWordPress分页没有出现
【发布时间】:2017-03-09 02:32:48
【问题描述】:

我试图在我的 wordpress 博客的两页上插入基本分页,但分页没有出现在页面底部。我不确定我做错了什么,因为我已经看到了许多其他示例,这些示例与我尝试实现的完全相同的代码工作得很好。任何帮助将不胜感激。

两个页面都使用的代码

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content-projects', get_post_format() );
endwhile;?> 
<nav>
<ul class="pager">
<li><?php next_posts_link( 'Previous' ); ?></li>
<li><?php previous_posts_link( 'Next' ); ?></li>
</ul>
</nav>  
<?php endif; ?>

【问题讨论】:

  • 你的帖子和每页帖子有多少?需要分页吗?
  • 这些页面上的内容将在我博客的整个生命周期内不断增加,因此分页是必要的
  • 我的意思是在这个时候,帖子数量是否足够(创建分页)或也没有

标签: php wordpress pagination


【解决方案1】:

以下代码非常适合我。可能这也对你有用。请按原样应用此代码。

<div class="nav">
<div class="alignleft numbers"><?php next_posts_link('&laquo; Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
</div>

另外一种添加分页的方法是使用插件。Click here

通过这种方式,您只需要添加短代码,例如:--

<div class="nav">
<?php wp_pagenavi(); ?>
</div>

【讨论】:

  • 将此代码放置在您应用分页代码的位置。表示代替 使用我建议的代码。
猜你喜欢
  • 1970-01-01
  • 2014-10-01
  • 2021-04-21
  • 1970-01-01
  • 1970-01-01
  • 2018-11-03
  • 1970-01-01
  • 2017-10-01
  • 2012-07-28
相关资源
最近更新 更多