OHIDUL951

portfolio-ajax-php

May 23rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1.  
  2. function maxive_ajax_pf_load_more(){
  3.  
  4.     $ppp = isset( $_POST['ppp'] ) ? $_POST['ppp'] : 3;
  5.     $paged = isset( $_POST['page'] ) ? $_POST['page'] : 2;
  6.     $paged++;
  7.  
  8.     $args = array(
  9.         'post_type' => 'portfolio',
  10.         'posts_per_page' => $ppp,
  11.         'paged'    => $paged,
  12.     );
  13.  
  14.     $posts = new WP_Query($args);
  15.  
  16.     if( $posts->have_posts() ) :  
  17.  
  18.         while( $posts->have_posts() ) :
  19.         $posts->the_post();
  20.  
  21.         // Get taxonomies for single portfolio posts
  22.         $types      = get_the_terms( $posts->ID, 'portfolio-type' );
  23.         $typesCount = count( $types );
  24.         $count      = 0;
  25.         $termArr = array();
  26.  
  27.         // Loop over throuth each the terms
  28.         if( $types ) {
  29.             foreach($types as $type) {
  30.                     $termArr[] = strtolower( $type->name ) ;
  31.             }
  32.         }
  33.  
  34.                 ?>
  35.                
  36.             <!-- contents will be ecohing from here. -->
  37.  
  38.  
  39.  
  40.     <?php
  41.  
  42.         endwhile;
  43.         wp_reset_postdata();
  44.                
  45.  
  46.     endif;
  47.  
  48.     die();
  49.  
  50.  
  51. }
  52.  
  53. add_action('wp_ajax_nopriv_maxive_ajax_pf_load_more', 'maxive_ajax_pf_load_more');
  54. add_action('wp_ajax_maxive_ajax_pf_load_more', 'maxive_ajax_pf_load_more');
Advertisement
Add Comment
Please, Sign In to add comment