【发布时间】:2020-06-20 06:00:57
【问题描述】:
我想借助自定义函数或钩子从店面 woocommerce 主题的购物车页面中删除页眉和页脚。
您能否建议我应该使用哪个功能来实现这一目标?
谢谢。
【问题讨论】:
标签: wordpress woocommerce customization hook-woocommerce storefront
我想借助自定义函数或钩子从店面 woocommerce 主题的购物车页面中删除页眉和页脚。
您能否建议我应该使用哪个功能来实现这一目标?
谢谢。
【问题讨论】:
标签: wordpress woocommerce customization hook-woocommerce storefront
你可以做两种方式。一种是使用 CSS,另一种是使用钩子。正如您特别询问钩子一样,我将提供钩子的代码。
您需要找出店面主题的页眉和页脚中使用了哪些钩子。然后在店面子主题中,创建一个functions.php文件(如果不存在,很可能确实存在),然后添加以下代码:
function remove_header_from_cart(){
if( is_cart() ){
remove_action( 'storefront_page', 'storefront_page_header', 10 );
remove_action( 'storefront_before_content', 'storefront_header_widget_region', 10 );
remove_action( 'storefront_header', 'storefront_header_container', 0);
remove_action( 'storefront_header', 'storefront_skip_links', 5 );
remove_action( 'storefront_header', 'storefront_site_branding', 20 );
remove_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
remove_action( 'storefront_header', 'storefront_product_search', 40 );
remove_action( 'storefront_header', 'storefront_header_container_close', 41 );
remove_action( 'storefront_header', 'storefront_primary_navigation_wrapper', 42 );
remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
remove_action( 'storefront_header', 'storefront_header_cart', 60 );
remove_action( 'storefront_header', 'storefront_primary_navigation_wrapper_close', 68 );
}
}
add_action('wp_head','remove_header_from_cart');
function remove_footer_from_cart(){
if( is_cart() ){
remove_action( 'storefront_footer', 'storefront_footer_widgets', 10 );
remove_action( 'storefront_footer', 'storefront_credit', 20 );
}
}
add_action('wp_head','remove_footer_from_cart');
【讨论】: