I need to remove specific body classes added as a comma separated delimited list to a custom field input field like this
wp-custom-logo, single-post, postid-28, single-format-standard, logged-in, admin-bar
Using this code only allows me to remove 1 class
add_filter('body_class', function (array $classes) {
if ( ! is_singular(array( 'post', 'page' ) ) ) {
return;
}
$body_classes = get_post_meta( get_the_ID(), '_remove_body_classes', true );
unset( $classes[array_search($body_classes, $classes)] );
return $classes;
});
This code works when trying to remove 1 class on single posts but doesn't work when using a comma delimited list and also doesn't work on single pages.