最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

pagination - the_posts_navigation is not working

programmeradmin0浏览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.

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.

Share Improve this question edited Aug 4, 2017 at 9:09 Johansson 15.4k11 gold badges43 silver badges79 bronze badges asked Dec 29, 2015 at 20:04 Md Jwel MiahMd Jwel Miah 1051 gold badge5 silver badges11 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

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

Place the_posts_navigationinside while loop hopefully it works!!

发布评论

评论列表(0)

  1. 暂无评论