Reputation: 4665
I'm trying to hide breadcrumbs with a child theme of storefront. This is the code I have in functions.php however, the conditional does not fire when on the cart page. Removing the conditional causes the breadcrumbs to be hidden
add_action('init', 'remove_shop_breadcrumbs' );
function remove_shop_breadcrumbs()
{
if ( is_cart())
{
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
}
}
From everything I can read, this is correct, does storefront replace this conditional with its own code, hence causing this to fail?
Upvotes: 0
Views: 1794
Reputation: 19308
You're code is firing too early. The init hook is triggered before the queries have been run therefore is_cart()
won't work. Use the wp
action instead.
Change this:
add_action('init', 'remove_shop_breadcrumbs' );
To this:
add_action( 'wp', 'remove_shop_breadcrumbs' );
Upvotes: 5