Skip to content

Instantly share code, notes, and snippets.

@michaelcarwile
Last active December 20, 2015 18:09
Show Gist options
  • Save michaelcarwile/6173805 to your computer and use it in GitHub Desktop.
Save michaelcarwile/6173805 to your computer and use it in GitHub Desktop.
Add WordPress slug to body class
<?php
// don't copy php tag
//* Slug as body class
function body_class_slug( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'body_class_slug');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment