/**
 * Theme Name:     Scacf
 * Author:         Quantico
 * Template:       hello-elementor
 * Text Domain:	   scacf
 * Description:    Spin Together
 */


// Escludi la categoria "uncategorized" da tutte le query WooCommerce
function nicola_exclude_uncategorized_products( $query ) {
    // Esegui solo sul frontend e per query principali
    if ( ! is_admin() && $query->is_main_query() ) {
        // Controlla se siamo su un archivio prodotti o shop
        if ( is_shop() || is_product_category() || is_product_taxonomy() || is_product_tag() || is_archive() ) {
            $tax_query = (array) $query->get('tax_query');

            $tax_query[] = array(
                'taxonomy' => 'product_cat',
                'field'    => 'slug',
                'terms'    => array( 'uncategorized' ), // slug della categoria da escludere
                'operator' => 'NOT IN',
            );

            $query->set( 'tax_query', $tax_query );
        }
    }
}
add_action( 'pre_get_posts', 'nicola_exclude_uncategorized_products' );