0

In our site we used to display categories and products in different separate sections when display type was set to 'both' using woocommerce_product_subcategories() function.

I have recently updated woocommerce to the latest v3.4.3 and found out that the function woocommerce_product_subcategories() has been deprecated. Now they have introduced different functions to display categories, like woocommerce_output_product_categories(), woocommerce_maybe_show_product_subcategories().

But the problem I'm having is that, I could not stop showing categories in product loop. It keeps showing both categories and products in the same loop.

Can anyone show me a way, how I can display categories and products in a separate section?

EDIT

To clarify my question, in my category settings, display type is set to both.

category setting

When I'm browsing category archive page, both category and products are showing in the loop.

enter image description here

What I want, is to separate categories from the loop and show it in a different section. In the loop, I want to display only products.

  • Your question is very confusing. Did you customize the WooCommerce shop pages? Did you use filters/actions to filter the WooCommerce results? Details are needed before anyone can really be of any assistance. – Steve Jul 5 '18 at 17:48
  • I have edited my question. Hope this will simplify to understand the problem. – Arif Jul 5 '18 at 18:09
  • The screenshot 'Display Type' is either a) a very old version of WooCommerce, b) a theme control, or c) a custom plugin. But it is definitely not native WooCommerce. Without knowing what theme or plugin you are using there isn't much we can do to help. – Steve Jul 5 '18 at 18:18
  • It is actually native to WC. Only plugin active is WooCommerce, and I'm using Storefront theme. Everything is updated to its latest version. – Arif Jul 5 '18 at 18:24
  • Not native WooCommerce, a Storefront theme control. You'll have to work with WooCommerce support to address the issue. – Steve Jul 5 '18 at 18:30
1

I have found the solution I was looking for. Using the following code will stop displaying categories in the product loop.

remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );

Then use the following function in a separate section of the page will render the categories in a separate section. woocommerce_maybe_show_product_subcategories()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.