Answer the question
In order to leave comments, you need to log in
How to do remove_action or remove_filter if add is done via anonymous function?
How to remove_action or remove_filter if add is done via an anonymous function?
add_filter( 'wp', function() { echo 'test'; }, 345 );
remove_filter( 'wp', function(){}, 345 );
Answer the question
In order to leave comments, you need to log in
assign an anonymous f-th to a variable. in the removal of the filter, hook specify it.
add_action( 'the_post', $my_the_post_action = function( $post_object ) {
// modify post object here
var_dump($post_object);
} );
remove_action('the_post' , $my_the_post_action);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question