A
A
Alexander Bondarenko2020-09-24 13:14:42
WordPress
Alexander Bondarenko, 2020-09-24 13:14:42

How to correctly display products of a certain Woocommerce category?

$args = array(
        'posts_per_page'=> 7,
        'post_type' => 'product',
        'post_status'   => 'publish',
         'category_name' => 'bazovaya-odezhda'
        ); 
        $the_query = new WP_Query( $args );

But there are no products found for this category, although they are, how to correctly display all products in this category?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ihor, 2020-09-24
@bond_1013

$args = array(
        'posts_per_page'=> 7,
        'post_type' => 'product',
        'post_status'   => 'publish',
        tax_query' => array(
    array(
        'taxonomy' => 'product_cat',
         'field' => 'slug',
        'terms' => 'тут слаг категории', 
    )
),
        ); 
        $the_query = new WP_Query( $args );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question