Remove product category block from home page of WooCommerce storefront theme
P粉908138620
P粉908138620 2023-09-03 15:33:39
0
1
586
<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>
P粉908138620
P粉908138620

reply all(1)
P粉322106755

To remove the product categories section from your storefront theme home page, you can use the following simple code snippet:

add_action( 'init', 'remove_storefront_home_product_categories', 10 );
function remove_storefront_home_product_categories(){
    // Unhook storefront_product_categories() function from 'homepage' action hook
    remove_action( 'homepage', 'storefront_product_categories', 20 );
}

The code is located in the functions.php file of the active child theme (or active theme). Tested and works.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!