• Как получить товары с заданным атрибутом woocommerce?

    @agletd Автор вопроса
    Сам нашел ответ.
    Если юзаете WP_Query с tax_query в functions.php поместите свой код в add_action с низким приоритетом:
    add_action( 'init', 'maratgenius', 999 );
    function maratgenius()
    {
                $newquery = new WP_Query( array(
                    'post_type'             => 'product',
                       'posts_per_page'        => '-1',
                       'post_status' => 'publish',
                       'tax_query' => array( array(
                           'taxonomy' => 'pa_chrisi', // Product attribute taxonomy: always start with 'pa_'
                           'field'    => 'term_id', // Can be 'term_id', 'slug' or 'name'
                           'terms'    => $_POST['get_what'],
                       ), ),
                
                ) );
    //other code
    }
    Ответ написан
    Комментировать