remove_filter()
doesn’t work unless it is used correctly. It needs to be called after the filter has been added, but before it is called. The discrepancy between snippets and functions.php is because snippets run at an earlier hook than functions.php.
Ladyfye:
Your example doesn’t work because you’re trying to remove the filter in the filter hook itself. This is too late to remove the filter, as it is already running. Try changing the action the wrapper function is hooked to:
function my_woocommerce_custom_breadcrumbs() {
if ( is_shop() ) {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
}
}
add_action('woocommerce_loaded','my_woocommerce_custom_breadcrumbs');
Terence:
I think the issue here is that you’re trying to remove a filter before is has been registered. Try wrapping it in a later hook:
add_action( 'init', function () {
global $post_series_manager;
// Remove the shortcode that's automatically added before the content
remove_filter( 'the_content', array( $post_series_manager, 'post_series_before' ) );
} );
It could also be an issue to do with access to the $post_series_manager
variable.