Remove product category block from home page of WooCommerce storefront theme
P粉908138620
2023-09-03 15:33:39
<p>I'm trying to remove the default product categories section block shown in the WooCommerce Storefront theme homepage. </p>
<p>I tried removing the block by using a couple of hooks in functions.php, for example: </p>
<pre class="brush:php;toolbar:false;">function remove_storefront_category() {
remove_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper', 9);
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10);
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20);
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30);
remove_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper_close', 31);
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_reset_loop', 999);
}
add_action( 'woocommerce_after_shop_loop', 'remove_storefront_category' );</pre>
<p>But no matter what I try, this product category section block won't disappear. </p>
<p>I searched a lot and only found information about hiding a specific category, but I want to hide it completely. </p>
To remove the product categories section from your storefront theme home page, you can use the following simple code snippet:
The code is located in the functions.php file of the active child theme (or active theme). Tested and works.