Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. //Ajax load more posts
  2. add_action( 'wp_ajax_load_more', 'load_more_callback' );
  3. add_action( 'wp_ajax_nopriv_load_more', 'load_more_callback' );
  4.  
  5. function load_more_callback() {
  6. $news = new WP_Query( array(
  7. 'post_type' => 'clients_cpt',
  8. 'order' => 'DESC',
  9. 'orderby' => 'date',
  10. 'posts_per_page' => $_POST['perpage'],
  11. 'offset' => $_POST['offset']
  12. ) );
  13. if ( $news->have_posts() ) {
  14. while ( $news->have_posts() ) {
  15. $news->the_post();
  16. show_template( 'clients-item', null, 'template-parts/cpt' );
  17. }
  18. }
  19. wp_die();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement