Add custom body class for specific pages

Adding this snippet to the functions.php of your wordpress theme will let you add a custom body class for specific pages.

 

add_filter( 'body_class', 'my_neat_body_class');
function my_neat_body_class( $classes ) {
if ( is_page(7) || is_category(5) || is_tag('neat') )
$classes[] = 'neat-stuff';
return $classes;
}

Leave a comment