Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

WP Ajax function

By: a guest on Mar 3rd, 2013  |  syntax: PHP  |  size: 0.75 KB  |  hits: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function wp_infinitepaginate() {
  2.         $loopFile = $_POST['loop_file'];
  3.         $paged = $_POST['page_no'];
  4.         $author_id = $_POST['author_id'];
  5.         $posts_per_page = get_option('posts_per_page');
  6.        
  7.        
  8.         # Load the posts
  9.        query_posts(array(
  10.             'author' => $author_id,
  11.             'paged' => $paged,
  12.             'posts_per_page' => $posts_per_page,
  13.             'post_status' => 'publish',
  14.         ));
  15.      
  16.        
  17.         get_template_part($loopFile);
  18.         wp_reset_query();
  19.  
  20.        exit;
  21.     }
  22.  
  23.     add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate');           // for logged in user
  24.     add_action('wp_ajax_nopriv_infinite_scroll', 'wp_infinitepaginate');    // if user not logged in