0

This question already has an answer here:

I need help on the pagination. I try to put the NEXT and PREVIOUS pagination that show the post in a same category, but I am not sure what happen that showing nothing.

If you can help, much thanks!

    <div class="row">
    <div class="page">
    <?php 
    $previous_post = get_previous_post('%link', 'Next post in category', TRUE);
    if ( $previous_post ) : ?>

    <!-- [ PREVIOUS ITEM ]-->
    <div class="col-xs-6">
    <?php if ( has_post_thumbnail( $previous_post->ID ) ) : ?>
    <?php echo get_the_post_thumbnail( $previous_post->ID, 'gallery-navigation' ); ?>
    <?php endif; ?>
    <a href="<?php echo get_permalink( $previous_post->ID ); ?>"><div class="info">
    <div class="info-gallery">
    <h2 class="title"><?php echo $previous_post->post_title; ?></h2>
    </div><!-- .info-content -->
    </div></a><!---info -->

    <span class="prevnext"><?php _e( 'Previous Featured', ); ?></span></div>
    <?php endif; //End of Previous Post Item ?>

    <?php $next_post = get_next_post('%link', 'Next post in category', TRUE);
    if ( $next_post ) : ?>

    <!-- [ NEXT ITEM ]-->
    <div class="col-xs-6">
    <?php if ( has_post_thumbnail( $next_post->ID ) ) { 
    echo get_the_post_thumbnail( $next_post->ID, 'gallery-navigation' ); }?>
    <a href="<?php echo get_permalink( $next_post->ID ); ?>"><div class="info">
    <div class="info-gallery">
    <h2 class="title"><?php echo $next_post->post_title; ?></h2>
    </div><!-- .info-content -->
    </div></a><!-- -info -->

    <span class="prevnext"><?php _e( 'Next Featured'); ?></span></div>
    <?php endif; //End of Next Post Item ?>

    </div>
    </div>

marked as duplicate by Brad Dalton, Howdy_McGee, TheDeadMedic, Robert hue, kaiser Jul 7 '15 at 23:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

get_previous_post() and get_next_post() are deprecated. You should use get_previous_post_link() and get_next_post_link() or even better the wrapper functions the_post_navigation() or get_the_post_navigation(). If you don't know how to use them, see the single.php template of the twentyfifteen theme that comes with WordPress by default. You can also see how these functions are implemented in the link-template.php file located in the wp-includes folder.

Not the answer you're looking for? Browse other questions tagged or ask your own question.