I want to hide woocommerce breadcrum in only woocommerce archive page. And i want to display it in single product. So i write this code in functions.php:

if(is_shop()) {
    remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);

But it not hiding.

closed as off-topic by Michael, Jacob Peattie, Krzysiek Dróżdż, Howdy_McGee Jun 3 '18 at 5:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.


is_shop() is returning false because the WordPress query isn't set up yet when functions.php is run. If you attach it to a hook, like wp_loaded, it should work.

add_action( 'wp_loaded', 'remove_main_content' );
function remove_main_content() {
  if( is_shop() ) {
    remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );

Not the answer you're looking for? Browse other questions tagged or ask your own question.