0

Looking to see if I can modify the below coding to pull just the category information. Currently at the category level it will pull all the products. Is it possible to just pull the subcategories and not the products?

Category_1 Subcategory_1 product_1 Subcategory_2 product_1 product_2

Want to just pull Subcategory_1, Subcategory_2.

$ids = array();
$cat = get_query_var('product_cat');
$args = array( 'post_type' => 'product', 'product_cat' => $cat );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product;

    $ids[] = $loop->post->ID;

endwhile;
wp_reset_query();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.