Php 用店面主题在woocommerce的购物车页面上隐藏面包屑
我试图用店面的儿童主题来隐藏面包屑。这是我在functions.php中的代码,但是,在购物车页面上不会触发条件。删除条件会导致面包屑被隐藏Php 用店面主题在woocommerce的购物车页面上隐藏面包屑,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我试图用店面的儿童主题来隐藏面包屑。这是我在functions.php中的代码,但是,在购物车页面上不会触发条件。删除条件会导致面包屑被隐藏 add_action('init', 'remove_shop_breadcrumbs' ); function remove_shop_breadcrumbs() { if ( is_cart()) { remove_action( 'storefront_content_top', 'woocommerce_bread
add_action('init', 'remove_shop_breadcrumbs' );
function remove_shop_breadcrumbs()
{
if ( is_cart())
{
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
}
}
据我所知,这是正确的,店面是否用自己的代码替换了这个条件,从而导致了失败?您的代码触发得太早了。init hook在查询运行之前被触发,因此
is\u cart()
将无法工作。改用wp
操作
更改此项:
add_action('init', 'remove_shop_breadcrumbs' );
为此:
add_action( 'wp', 'remove_shop_breadcrumbs' );
你是说代码发射太早了。init hook在查询运行之前被触发,因此
is\u cart()
将无法工作。改用wp
操作
更改此项:
add_action('init', 'remove_shop_breadcrumbs' );
为此:
add_action( 'wp', 'remove_shop_breadcrumbs' );
谢谢,现在可以用了。这很有趣,因为我实际上从woothemes的文档中得到了init钩子!谢谢,现在可以用了。这很有趣,因为我实际上从woothemes的文档中得到了init钩子!