function wp_infinitepaginate() { $loopFile = $_POST['loop_file']; $paged = $_POST['page_no']; $author_id = $_POST['author_id']; $posts_per_page = get_option('posts_per_page'); # Load the posts query_posts(array( 'author' => $author_id, 'paged' => $paged, 'posts_per_page' => $posts_per_page, 'post_status' => 'publish', )); get_template_part($loopFile); wp_reset_query(); exit; } add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate'); // for logged in user add_action('wp_ajax_nopriv_infinite_scroll', 'wp_infinitepaginate'); // if user not logged in