Support » Plugins and Hacks » WooCommerce » How to list only grouped products in WooCommerce's categories

Viewing 2 replies - 1 through 2 (of 2 total)
  • Zafi

    (@zaffarn)


    Hi Machi

    Did you manage to get this sorted, I have same requirement.

    Hi,

    Add the below snippet inside your functions.php file

    function filter_grouped_products( $query ) {
      if ( !is_admin() && is_shop() && $query->is_main_query() ) {
        $query->set('post_type', 'product');
        $product_type = array(
          'taxonomy' => 'product_type',
          'field' => 'slug',
          'terms' => 'grouped'
        );
        $query->set('tax_query', array($product_type) );
      }
    }
    add_action('pre_get_posts', 'filter_grouped_products');

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to list only grouped products in WooCommerce's categories’ is closed to new replies.