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 );
}
}