1

WordPress hack: Automatically add post name to the body class

http://feedproxy.google.com

The only thing you have to do is to copy the following function and paste it on your theme functions.php file. Once saved, the post/page name will be automatically be added to the body class.

function wpprogrammer_post_name_in_body_class( $classes ){
if( is_singular() )
{
global $post;
array_push( $classes, "{$post->post_type}-{$post->post_name}" );
}
return $classes;
}

add_filter( 'body_class', 'wpprogrammer_post_name_in_body_class' );

Thanks to Utkarsh Kukreti for this great hack!
Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress hack: Automatically add post name to the body class

Read »
Created by bands 1 year 22 weeks ago – Made popular 1 year 22 weeks ago
Category: Programming   Tags:

Your Ad Here

User login

Who's online

There are currently 0 users and 1 guest online.

Best karma users

  1. bands
  2. sri's picture
    sri
  3. shashi
  4. sunnyholic
  5. admin user