K
K
krinbin2019-12-09 23:09:21
WordPress
krinbin, 2019-12-09 23:09:21

Why don't filters work in woocommerce custom taxonomy?

Made a custom category in WC.
The output goes like this

woocommerce_product_loop_start();

$args = array(
'tax_query' => array(
'relation' => 'AND', 
array(
'taxonomy' => 'product_cat',
'field' => 'ID',
'terms' => $term,
),
array(
'taxonomy' => $attribute,
'field' => 'ID',
'terms' => $term_2,
)
),
'posts_per_page' => 6, 
'post_type' => 'product', 
'orderby' => 'rand', 
);

$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post();
do_action('woocommerce_shop_loop');		
wc_get_template_part('content', 'product');
endwhile; 
wp_reset_query(); 	
woocommerce_product_loop_end();

But the filtering in the widgets does not work. WC does not see the attributes of the goods that are in the listing.
If you take a standard template from a category and add a product through the admin panel (as usual), then the filters work.
Here is a snippet of standard output
woocommerce_product_loop_start();

  if ( wc_get_loop_prop( 'total' ) ) {
    while ( have_posts() ) {
      the_post();

      /**
       * Hook: woocommerce_shop_loop.
       */
      do_action( 'woocommerce_shop_loop' );

       wc_get_template_part( 'content', 'product' );
  }
  }

  woocommerce_product_loop_end();

How to be? Can it be fixed or not?
Thanks to all :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question