如何移除WooCommerce Storefront主题首页的产品分类区块
移除Storefront主题首页默认产品分类区块的正确方法
你当前的代码无效是因为操作的是商店页面产品循环后的钩子,和首页的产品分类区块不属于同一钩子体系。以下是两种可行方案:
方案1:通过钩子移除(代码方式)
Storefront主题的首页产品分类区块是通过storefront_product_categories函数挂载到storefront_homepage钩子上的,默认优先级为10。将以下代码添加到子主题的functions.php中:
// 移除首页产品分类区块 function remove_storefront_homepage_categories() { remove_action( 'storefront_homepage', 'storefront_product_categories', 10 ); } add_action( 'init', 'remove_storefront_homepage_categories' );
方案2:通过后台自定义面板关闭(无需代码)
Storefront主题自带首页布局可视化设置,直接在后台操作更简便:
- 进入WordPress后台 → 外观 → 自定义
- 找到「首页设置」或「首页内容」选项
- 取消勾选「产品分类」区块的显示开关,保存更改即可
内容的提问来源于stack exchange,提问作者Daniel
相关产品推荐
相关产品推荐

