Taxonomy Filter with Ajax in not working infinite scroll
-
// ajax code for request test ride details add_action( 'wp_ajax_nopriv_request_by_filter', 'request_by_filter' ); add_action( 'wp_ajax_request_by_filter', 'request_by_filter' ); function request_by_filter() { $typecatArr = $_POST['typearr']; //print_r($typecatArr); $type_arr = explode (",", $typecatArr); $finishcatArr = $_POST['finisharr']; //print_r($finishcatArr); $finish_arr = explode (",", $finishcatArr); $sizecatArr = $_POST['sizearr']; //print_r($sizecatArr); $size_arr = explode (",", $sizecatArr); $post_type = $_POST['post_type']; $type = $_POST['type']; $finish = $_POST['finish']; $size = $_POST['size']; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array( 'post_type' => $post_type, 'posts_per_page'=> 12, 'paged' => $paged, 'post_status' =>'publish', 'orderby' => 'menu_order', 'order' => 'DESC' ); if($type_arr || $finish_arr || $size_arr) { $tax_query['tax_query'] = array( 'relation'=>'AND' ); } $args = array_merge_recursive( $args, $tax_query); if(!empty($typecatArr)) { $tax_query['tax_query'] = array( array( 'taxonomy' => $type, 'field' => 'term_id', 'terms' => $type_arr, ) ); $args = array_merge_recursive( $args, $tax_query); // print_r($args); } if(!empty($finishcatArr)) { $tax_query['tax_query'] = array( array( 'taxonomy' => $finish, 'field' => 'term_id', 'terms' => $finish_arr, ) ); $args = array_merge_recursive( $args, $tax_query); // print_r($args); } if(!empty($sizecatArr)) { $tax_query['tax_query'] = array( array( 'taxonomy' => $size, 'field' => 'term_id', 'terms' => $size_arr, ) ); $args = array_merge_recursive( $args, $tax_query); } $query = new WP_Query($args); if ( $query->have_posts() ) { ?> <div class="ajaxloader col-lg-10 col-md-9" id="ajaxloaderdiv" style="display:none;"> <img class="loading-image" src="<?php echo get_stylesheet_directory_uri(); ?>/framework/loader.gif" /> </div> <div class="products-zindex"> <div class="row"> <?php while ( $query->have_posts() ) { $query->the_post(); $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full'); $procatArr = wp_get_post_terms( get_the_ID(), $finish ); ?> <div class="col-sm-3 col-md-6 col-lg-4 col-xl-2 ajaxscrollload"> <div class="zindex-product-detail"> <a href="<?php echo get_permalink(); ?>"> <div class="product-img"> <img src="<?php echo $featured_img_url; ?>" alt="<?php the_title(); ?>" class="img-fluid"> </div> <div class="product-data"> <h5><?php the_title(); ?></h5> <h6> <?php $comma_string = array(); foreach( $procatArr as $catval ) { $comma_string[] = $catval->name; } echo $productname = implode(", ", $comma_string); ?> </h6> </div> </a> </div> </div> <?php } echo "<nav class=\"ajaxsw-pagination\">"; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $the_query->max_num_pages ) ); echo "</nav>"; wp_reset_query(); ?> </div> </div> <?php } else { ?> <h2>No Product Found.</h2> <?php } wp_die(); //exit; }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Taxonomy Filter with Ajax in not working infinite scroll’ is closed to new replies.