Blog for web designers

Add class to specific post

Add class to specific post if its not home

Ever wonder if you want to add a specific class for specific post in the body element.

Below code will help you to add a class if its not a home page.

add_filter( 'body_class', 'my_neat_body_class');
function my_neat_body_class( $classes ) {
     if (! is_home())
          $classes[] = 'not-home';
     return $classes;

Php snippets

>body >?php body_class(); ?<

Santosh Shah

My name is Santosh Shah and blogs at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.