Load Previous Posts always loads latest post first
-
Good day, I have been trying to set up infinity scroll on localhost (for testing purposes before adding to live site) using the shortcode in the single.php file and the default repeater template that has get_template_part(). My problem is that when i open a single blog post, the latest blog post is loaded instead. This happens on all the blog posts i click on, even the oldest one. The plugin overrides the post to be loaded and load the latest post instead.
Please note that i am trying to do infinite scrolling only on single posts and not on post listing e.g the homepage.
The following is my single.php :
get_header(); ?> <div class="wrap"> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php /* Start the Loop */ while ( have_posts() ) : the_post(); echo do_shortcode('[ajax_load_more post_type="post" repeater="default" previous_post="true" previous_post_id="'. get_the_ID() .'" posts_per_page="2" button_label="Previous Posts"]'); endwhile; // End of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> </div><!-- .wrap --> <?php get_footer();
And my Repeater Template :
<?php global $post; get_template_part( 'template-parts/post/content', get_post_format() ); ?>
- The topic ‘Load Previous Posts always loads latest post first’ is closed to new replies.