0

Unfortunately, the_posts_navigation() function is not working for me. When I click on 'Older Posts' it's showing '404 page I don't know why my code is not working.

Here is the code -

<div class="row">
    <?php while ( have_posts() ) : the_post(); ?> 
    <div class="col-md-3 thumbnailu">
        <a class="thmb" href="<?php echo get_post_meta ($post->ID, 'link_name', true); ?>" target="_blank">
        <?php 
        the_post_thumbnail( 'website-image-size', array( 'class' => 'img-responsive' ) ); 
    ?>

        <p class="caption"><?php the_title(); ?><br> 
        by <?php echo get_post_meta ($post->ID, 'author_name', true); ?> </p>
        </a>
    </div>

<?php endwhile; ?>

<?php the_posts_navigation(array(
    'prev_text' => 'Older Posts',
    'next_text' => 'Newer Posts',
    'screen_reader_text' => ' ',
));
?>

It's showing the same error even I use the previous_posts_link() function.

0

This function uses get_the_posts_pagination() which uses the GLOBAL $wp_query to setup the paginate_links() function, so I believe that doesn't work for get_posts.

Try use the function paginate_links() by itself or the function posts_nav_link()

-1

Place the_posts_navigationinside while loop hopefully it works!!

  • 1
    Could you explain why should it help? It doesn’t make much sense for me... – Krzysiek Dróżdż Mar 24 '18 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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