Skip to content

Instantly share code, notes, and snippets.

@caseydriscoll
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseydriscoll/33c49292b3fa8eb1de18 to your computer and use it in GitHub Desktop.
Save caseydriscoll/33c49292b3fa8eb1de18 to your computer and use it in GitHub Desktop.
Page slug to body class
// Page Slug Body Class
// http://www.wpbeginner.com/wp-themes/how-to-add-page-slug-in-body-class-of-your-wordpress-themes/
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment