Get second page of Author's post for WP While loop
-
I have an author page (author.php) which shows his 10 posts or page 1 with “View more” button at the bottom. After clicking “View more” button I want to fetch next page of author’s post. I am implementing this using Ajax for infinite scrolling.
function wp_infinitepaginate() { $loopFile = $_POST['loop_file']; $paged = $_POST['page_no']; $posts_per_page = get_option('posts_per_page'); # Load the posts query_posts(array('paged' => $paged)); get_template_part($loopFile); wp_reset_query(); exit; } add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate');
In loop file I am having simple loop to display posts
while (have_posts()) : the_post();
But this loop prints all the posts in the site!! How can I make it print from second page of author’s page.
If I have made it complicated, here is easy version I am using wordpress while loop twice in same page. Suppose first while loop fetches page 1 then, How will second while loop fetch page 2?
I followed this tutorial if this helps to understand : Infinite scroll tutorial
- The topic ‘Get second page of Author's post for WP While loop’ is closed to new replies.