wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Setup whitelist body_class to remove unwanted classes

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will let you create a white-list of terms to include in body_class. This is a great way to filter out many of the unwanted classes added

snippet :  PHPcopy
add_filter('body_class', 'wps_body_class', 10, 2);
function wps_body_class($wp_classes, $extra_classes)
    // List of classes allowed
    $whitelist = array('portfolio', 'home', 'error404');
    $wp_classes = array_intersect($wp_classes, $whitelist);
    return array_merge($wp_classes, (array) $extra_classes);
source →

Did you like this post? If so please share it with your friends. Thanks!