My parent theme generates the following class in body
: style-cupcake
. I don’t want that. The best way to get rid of this is by adding my own functions in a functions.php
file in my child theme, right?
I tried this (a solution I found on WPSE) but it does not seem to work. “custom background” is removed, but style-cupcake persists.
<?php
function my_body_class( $wp_classes, $extra_classes )
{
// List of the only WP generated classes that are not allowed
$blacklist = array('custom-background', 'style-cupcake');
// Blacklist result: (uncomment if you want to blacklist classes)
$wp_classes = array_diff( $wp_classes, $blacklist );
// Add the extra classes back untouched
return array_merge( $wp_classes, (array) $extra_classes );
}
add_filter( 'body_class', 'my_body_class', 10, 2 );
?>
Any idea?
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 â¦
⦠will make sure
my_body_class()
will be called afteranother_body_class()
that has been registered with 10:Also note the priority argument will be used as an array key. It doesnât have to be a number, just a valid key.