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.
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.
2 Answers
Reset to default 1This 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()
Place the_posts_navigation
inside while loop hopefully it works!!