【问题标题】:WordPress custom post previous and next link not workingWordPress自定义帖子上一个和下一个链接不起作用
【发布时间】:2014-11-18 04:10:03
【问题描述】:

我使用 WordPress 和 bootstrap 创建了自定义主题,除了 singe.php 中的上一个和下一个链接外,一切正常。

这是我的代码:

<?php get_header(); ?>

<article>
<div class="container single-project">

<?php if (have_posts()) : while (have_posts()) : the_post();?>

<div class="row">
        <div class=" col-md-4 col-lg-4 pull-right">
        <header class="entry-header">
        <h1 id="post-<?php the_ID(); ?>"><?php the_title();?></h1>
        <hr>
        </header><!-- .entry-header -->
</div>

<div class=" hidden-md hidden-lg"><hr></div>

<div class="col-md-4 col-lg-4"><?php the_content(); ?></div>

<?php previous_posts_link() ?>
<?php next_posts_link() ?>

</div>   <!-- end of row -->
</div>  <!-- end of container -->

<?php endwhile; endif; ?>

</article>

<?php get_footer(); ?>

提前致谢。

【问题讨论】:

    标签: php wordpress post hyperlink next


    【解决方案1】:

    你必须移动

    <?php previous_posts_link() ?>
    <?php next_posts_link() ?>
    

    之后

    </article>
    

    最好在某个 div 中,这样你就可以设置它的样式,比如

    <div class="navi">
        <?php previous_posts_link() ?>
        <?php next_posts_link() ?>
    </div>
    

    【讨论】:

      【解决方案2】:

      找到解决方案:

      <?php previous_post('&laquo; &laquo; %', 'Previous Post', 'yes'); ?> |
      <?php next_post('% &raquo; &raquo; ', 'Next Post', 'yes'); ?>
      

      http://wpsites.net/web-design/previous-next-single-post-navigation-links-wordpress/

      【讨论】:

      • 自 WordPress 2.0.0 起不推荐使用这些方法,而是使用上面的 next_post_link() 代替
      猜你喜欢
      • 2012-07-20
      • 1970-01-01
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 2017-07-17
      • 1970-01-01
      • 2018-02-11
      相关资源
      最近更新 更多