Advertisement
Guest User

WP Ajax function

a guest
Mar 3rd, 2013
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement