Display WooCommnerce products and subcategories on separate rows with Astra
-
Hi,
Woocommerce categories and products appear on the same row, in the same ul element. I personally find this confusing and was looking for a way to separate them. I wanted to show the categories before/above the products.
I found this code:
// 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>'; } }
Source: https://www.commercegurus.com/docs/shoptimizer-theme/products-subcategories-separate/
It works, but the categories are now showing twice: In their new place (before the shop loop, just above the ordering filter options), AND in the shop loop alongside with the products (the default place where they already were before).
WooCommerce support team said it looks related to the theme (see original topic). Can someone help me find the way to prevent them to show a second time in the shop loop?
The page I need help with: [log in to see the link]
- The topic ‘Display WooCommnerce products and subcategories on separate rows with Astra’ is closed to new replies.