Created
April 6, 2017 21:57
-
-
Save donnamcmaster/e5091aee1773823335e2c3e77962e102 to your computer and use it in GitHub Desktop.
WordPress: adds the post type and slug to the <body> class, e.g., "page-about"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds the post type and slug to the <body> class, e.g., "page-about". | |
*/ | |
add_filter( 'body_class', function( $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