简体   繁体   中英

WordPress custom post previous and next link not working

I created custom theme with WordPress and bootstrap and everything works fine except previous and next link in singe.php.

Here is my code:

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

Thanks in advance.

You have to move

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

after

</article>

preferably inside some div so you can style it, like

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

Found solution:

<?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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM