• Hello,

    I am trying to use following snippet to separate subcategories from product loop:

    // Remove subcategories from the product loop
    remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );

    // Add subcategories before the product loop with priority 5
    add_action( 'woocommerce_before_shop_loop', 'cg_show_product_subcategories', 5 );

    function cg_show_product_subcategories() {
    $subcategories = woocommerce_maybe_show_product_subcategories();
    if ( $subcategories ) {
    echo '<ul class="products subcategories">', $subcategories, '</ul>';
    }
    }

    It separates subcategories from products, but lists subcategories in 1 column, and I don’t know where should I change it. Below is the picture where subcategories end, and products start:

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Check below solution

    add_action( 'woocommerce_before_shop_loop', 'cuwoo_product_categories' );
    function cuwoo_product_categories(){
    $output = '';
    $output = woocommerce_output_product_categories(['parent_id' => get_queried_object_id()]);
    return $output;
    }

    Thanks

    Thread Starter avzone

    (@avzone)

    Hello @ravindra107,

    It lists the subcategories but it’s still in one columny with thumbnails stretched as shown in the first post.

    Best regards

    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @avzone,

    Thank you for reaching out. I’m not entirely sure what you’re aiming for. Aside from the custom code you’ve added, could you clarify your goal? Are you trying to display product categories without their subcategories, or do you want to show products from a category while excluding those from its subcategories?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.