Title: drowosek's Replies | WordPress.org

---

# drowosek

  [  ](https://wordpress.org/support/users/drowosek/)

 *   [Profile](https://wordpress.org/support/users/drowosek/)
 *   [Topics Started](https://wordpress.org/support/users/drowosek/topics/)
 *   [Replies Created](https://wordpress.org/support/users/drowosek/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/drowosek/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/drowosek/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/drowosek/engagements/)
 *   [Favorites](https://wordpress.org/support/users/drowosek/favorites/)

 Search replies:

## Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[YITH Infinite Scrolling] How to stop infinity scroll](https://wordpress.org/support/topic/how-to-stop-infinity-scroll/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/how-to-stop-infinity-scroll/#post-15738882)
 * Maybe it will be useful for somebody. I solved this problem:
 * This code for turn off plugin (I insert it after receiving ajax data)
 *     ```
       $( window ).on( 'scroll touchstart', function (){
                   $(this).trigger('yith_infs_start').off("scroll");
                   $(this).trigger('yith_infs_start').off("touchstart");
               });
       ```
   
 * This code for turn on plugin (I insert it in a function which is run when filter
   is clean)
 *     ```
        $( window ).on( 'scroll touchstart', function (){
               $(this).trigger('yith_infs_start').on("scroll");
               $(this).trigger('yith_infs_start').on("touchstart");
           });
       ```
   
 * I know that it is not a perfect solution because we can use
    `.off("scroll","
   touchstart")` but in my case it does not work.
    -  This reply was modified 3 years, 12 months ago by [drowosek](https://wordpress.org/support/users/drowosek/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[YITH Infinite Scrolling] How to stop infinity scroll](https://wordpress.org/support/topic/how-to-stop-infinity-scroll/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/how-to-stop-infinity-scroll/#post-15735944)
 * I solved this issue, with inserting this code:
 *     ```
       $( window ).on( 'scroll touchstart', function (){
          $(this).trigger('yith_infs_start').off();
       });
       ```
   
 * but I have another one problem after the cleaning filter, I try to re-initialize
   infinity scrolling like this
 *     ```
        $( window ).on( 'scroll touchstart', function (){
               $(this).trigger('yith_infs_start').on();
           });
       ```
   
 * but it`s not working.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[YITH Infinite Scrolling] How to stop infinity scroll](https://wordpress.org/support/topic/how-to-stop-infinity-scroll/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [3 years, 12 months ago](https://wordpress.org/support/topic/how-to-stop-infinity-scroll/#post-15733344)
 * Thank you for your hint! I tried to block event scroll, but it does not work.
   Maybe I used it incorrect. I insert this code after ajax response. I think logically
   it is good. Could you check it?
 *     ```
       $( window ).on( 'scroll touchstart', function (){
           $(this).trigger('yith_infs_start');
          });
        $( window ).on( 'yith_infs_start', function (){
          return false;
          }); 
       ```
   
    -  This reply was modified 3 years, 12 months ago by [drowosek](https://wordpress.org/support/users/drowosek/).
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Custom ajax filter by terms](https://wordpress.org/support/topic/custom-ajax-filter-by-terms/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/custom-ajax-filter-by-terms/#post-15603486)
 * maybe, somebody will need it, i solve this issue.
 *     ```
       function product_scripts()
       {
   
           wp_register_script('custom-script', get_stylesheet_directory_uri() . '/lib/ajax-products-filter.js', array('jquery'), false, true);
   
           $script_data_array = array(
               'ajaxurl' => admin_url('admin-ajax.php'),
               'security' => wp_create_nonce('load_products'),
           );
           wp_localize_script('custom-script', 'blog', $script_data_array);
           wp_enqueue_script('custom-script');
       }
   
       add_action('wp_enqueue_scripts', 'product_scripts');
   
       add_action('wp_ajax_load_posts_by_ajax', 'load_posts_by_ajax_callback');
       add_action('wp_ajax_nopriv_load_posts_by_ajax', 'load_posts_by_ajax_callback');
       function load_posts_by_ajax_callback()
       {
       check_ajax_referer('load_products', 'security');
       $paged = $_POST['page'];
       $category = $_POST['category'];
       $colors = $_POST['colors'];
       ?>
           <ul class="products results-js" style="display: grid">
       <?php
   
           $args = array(
               'post_type' => 'product',
               'post_status' => 'publish',
               'posts_per_page' => -1,
               'paged' => $paged,
               'meta_query' => array(
                   'key' => '_visibility',
                   'value' => array('catalog', 'visible'),
                   'compare' => 'IN',
               ),
               'tax_query' => array(
                   'relation' => 'AND',
                  array(
                          'relation' => 'OR',
                       array(
                       'taxonomy' => 'product_cat',
                       'field'    => 'slug',
                       'terms'    => $category,
                       'operator' => 'IN',
                        ),
                         array(
                       'taxonomy' => 'by-gift',
                       'field'    => 'slug',
                       'terms'    => $category,
                       'operator' => 'IN',
                        ),
                        array(
                       'taxonomy' => 'by-room',
                       'field'    => 'slug',
                       'terms'    => $category,
                       'operator' => 'IN',
                        ),
                   ),
                   array(
                     'taxonomy' => 'pa_colors',
                     'field'    => 'name',
                     'terms'    => $colors,
                     'operator' => 'IN',
                   )
                 )
           );
               $loop= new WP_Query($args);
               if ( $loop->have_posts() ) {
                   while ( $loop->have_posts() ) : $loop->the_post();
                       wc_get_template_part( 'content', 'product' );
                   endwhile;
               } else {
                   echo __( '<p class="woocommerce-info">No products were found matching your selection.</p>' );
               }
               wp_reset_postdata();
   
           ?>
       </ul>
   
           <?php
           wp_die();
       }
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Custom ajax filter by terms](https://wordpress.org/support/topic/custom-ajax-filter-by-terms/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/custom-ajax-filter-by-terms/#post-15603372)
 * Problem solved partly, now I recieve products by colors, but not by category.
   I think something wrong in query by category..
 *     ```
       $args = array(
               'post_type' => 'product',
               'post_status' => 'publish',
               'posts_per_page' => -1,
               'paged' => $paged,
               'meta_query' => array(
                   'key' => '_visibility',
                   'value' => array('catalog', 'visible'),
                   'compare' => 'IN',
               ),
               'tax_query' => array(
                   'relation' => 'AND',
                  array(
                       'taxonomy' => 'products-cat',
                       'field'    => 'slug',
                       'terms'    => $category,
                       'operator' => 'IN',
                   ),
                   array(
                     'taxonomy' => 'pa_colors',
                     'field'    => 'name',
                     'terms'    => $colors,
                     'operator' => 'IN',
                   )
                 )
           );
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Custom ajax filter by terms](https://wordpress.org/support/topic/custom-ajax-filter-by-terms/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/custom-ajax-filter-by-terms/#post-15599222)
 * Partly solved, but I recieve all the products
 *     ```
       $('.button-filter').click(function () {
           var page = 1;
   
           if ( $(this).hasClass('active-js')){
               $(this).removeClass('active-js')
           }else{
               $(this).addClass('active-js')
               $('.clear-js').fadeIn()
           }
               var colors = [];
           $('.button-filter.active-js').each(function (){
              var r = $(this).data('color');
              colors.push(r);
           })
           if (colors.length == 0){
               clearFilter()
           }
           console.log(colors)
           var category = $('.page-title').html()
           console.log(category)
           var data = {
               'action': 'load_posts_by_ajax',
               'security': blog.security,
               'page': page,
               'category': category,
               'colors': colors,
           };
           console.log(data)
           $.post(blog.ajaxurl, data, function (response) {
               console.log(response)
               if ($.trim(response) != '') {
                   console.log(response)
                   $('.products').fadeOut()
                   $('.all-product-grid').fadeOut()
                   $('#wc-column-container').append(response);
                   page++;
               }
           });
       });
       function clearFilter(){
           $('.button-filter').each(function () {
               $(this).removeClass('active-js')
               $('.clear-js').fadeOut()
               $('.products').fadeIn()
               $('.all-product-grid').fadeIn()
           })
       }
       ```
   
 * and php
 *     ```
       function product_scripts()
       {
   
           wp_register_script('custom-script', get_stylesheet_directory_uri() . '/lib/ajax-products-filter.js', array('jquery'), false, true);
   
           $script_data_array = array(
               'ajaxurl' => admin_url('admin-ajax.php'),
               'security' => wp_create_nonce('load_products'),
           );
           wp_localize_script('custom-script', 'blog', $script_data_array);
           wp_enqueue_script('custom-script');
       }
   
       add_action('wp_enqueue_scripts', 'product_scripts');
   
       add_action('wp_ajax_load_posts_by_ajax', 'load_posts_by_ajax_callback');
       add_action('wp_ajax_nopriv_load_posts_by_ajax', 'load_posts_by_ajax_callback');
       function load_posts_by_ajax_callback()
       {
       check_ajax_referer('load_products', 'security');
       $paged = $_POST['page'];
       $category = $_POST['category'];
       $colors = $_POST['colors'];
       ?>
           <ul class="products-js">
       <?php
   
           $loop = new WP_Query(array(
               'post_type' => 'product',
   
             'category' => $category,
               'post_status' => 'publish',
               'posts_per_page' => -1,
               'paged' => $paged,
               'meta_query' => array(
                   'key' => '_visibility',
                   'value' => array('catalog', 'visible'),
                   'compare' => 'IN',
               ),
               'tax_query' => array(
                   'taxonomy' => 'pa_colors',
                   'field' => 'slug',
                   'terms' => $colors,
                   'operator' => 'IN',
               )
           ));
               if ( $loop->have_posts() ) {
                   while ( $loop->have_posts() ) : $loop->the_post();
                       wc_get_template_part( 'content', 'product' );
                   endwhile;
               } else {
                   echo __( 'No products found' );
               }
               wp_reset_postdata();
   
           ?>
       </ul><!–/.products–>
   
           <?php
           wp_die();
       }
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Change product card template woocommerce](https://wordpress.org/support/topic/change-product-card-template-woocommerce/)
 *  Thread Starter [drowosek](https://wordpress.org/support/users/drowosek/)
 * (@drowosek)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/change-product-card-template-woocommerce/#post-15595567)
 * I just made the wrap before and after 7th product and it works

Viewing 7 replies - 1 through 7 (of 7 total)