wordpress - woocomerce - 从商店登陆页面中删除面包屑 [英] wordpress - woocomerce - remove breadcrumbs from shop landing page
本文介绍了wordpress - woocomerce - 从商店登陆页面中删除面包屑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 woocommerce 的 wordpress.我正在尝试停止在列出我在厕所设置中设置为商店页面"的类别的页面上显示的面包屑.
I have wordpress with woocommerce. I am trying to stop the breadcrumbs displaying on the page that lists the categories which I have set as the 'shop page' in the wc settings.
页面的 id 是 '5' 并且它有名称/slug 'materials'
The id of the page is '5' and it has the name/slug 'materials'
在我的functions.php中我已经把
in my functions.php I have put
if (is_page('materials')){
add_action( 'init', 'am_remove_wc_breadcrumbs' );
}
function am_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
我已将 if 语句中的选择器更改为 5 - 也不高兴.如果我删除 add_action 周围的 if 语句,那么面包屑将从所有页面中删除 - 正如您所期望的那样.
i have changed the selector in the if statement to 5 - no joy either. If I remove the if statement around the add_action then the breadcrumbs are removed from all the pages - as you'd expect.
推荐答案
试试看:
add_action('template_redirect', 'remove_page_breadcrumbs' );
function remove_page_breadcrumbs(){
if (is_page('YOUR_PAGE_ID_OR_SLUG'))
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
}
这篇关于wordpress - woocomerce - 从商店登陆页面中删除面包屑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文