Skip to content

Instantly share code, notes, and snippets.

@bmdinteractive
Created August 7, 2017 15:29
Show Gist options
  • Save bmdinteractive/65c88d0f80ad6dc6afe1e97c04a7b32c to your computer and use it in GitHub Desktop.
Save bmdinteractive/65c88d0f80ad6dc6afe1e97c04a7b32c to your computer and use it in GitHub Desktop.
Add page slug to body class
//Page Slug Body Class
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