Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用店面主题在woocommerce的购物车页面上隐藏面包屑_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 用店面主题在woocommerce的购物车页面上隐藏面包屑

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

我试图用店面的儿童主题来隐藏面包屑。这是我在functions.php中的代码,但是,在购物车页面上不会触发条件。删除条件会导致面包屑被隐藏

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钩子!