How to filter products by category in custom loop

  1. Use $term->term_id instead of slug as the option value.

  2. Check if the $_GET['product-category'] exists, then append it to the $args array.

     $args = array(
         'post_type' => 'product',
         'posts_per_page' => 6,
         'paged' => 1
     );  
    
     if ( isset($_GET['product-category']) && !empty($_GET['product-category']) ) {
         $args['tax_query'] = array(
             array(
                 'taxonomy' => 'product_cat',
                 'terms' => $_GET['product-category'],
             ),
         );
     }
    
     $loop = new WP_Query($args);
    

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino