I don’t need this whole mess of classes like this…
<body class="page page-id-829 page-template page-template-page-template-portfolio-php portfolio">
I’d like something like this…
<body class="portfolio">
Is there a filter snippet somewhere that has a list of all the classes and I can then just uncomment the stuff I don’t want to see in the body class.
Thanks.
You can configure the $whitelist
array in this function to filter out all other unwanted classes.
add_filter( 'body_class', 'wpse15850_body_class', 10, 2 );
function wpse15850_body_class( $wp_classes, $extra_classes ) {
// List of the only WP generated classes allowed
$whitelist = array( 'portfolio', 'home', 'error404' );
// Filter the body classes
$wp_classes = array_intersect( $wp_classes, $whitelist );
// Add the extra classes back untouched
return array_merge( $wp_classes, (array) $extra_classes );
}