Remove class that has been added by parent theme

If you want to apply a filter to the same content another function has filtered, change the priority argument (which should have been named _execution_order_) to a higher number.

So …

add_filter( 'body_class', 'my_body_class', 11, 2 );

… will make sure my_body_class() will be called after another_body_class() that has been registered with 10:

add_filter( 'body_class', 'another_body_class', 10, 2 );

Also note the priority argument will be used as an array key. It doesn’t have to be a number, just a valid key.

// this works!
add_filter( 'body_class', 'my_body_class', 'very late please', 2 );
add_filter( 'body_class', 'my_body_class', PHP_INT_MAX, 2 );

Leave a Comment