Skip to content

Instantly share code, notes, and snippets.

@elvinlee
Created July 29, 2015 09:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save elvinlee/5c99cc8e9e8e98c11616 to your computer and use it in GitHub Desktop.
WordPress: Add Post Type & Post Name to Body Class
/**
* Add Post Type & Post Name to Body Class
* For example: page-about-us
*/
add_filter('body_class', 'add_post_class');
function add_post_class($classes) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment