Last active
August 29, 2015 14:14
-
-
Save likesalmon/6df53215a0f91cf4864a to your computer and use it in GitHub Desktop.
Add page slug to body_class() template variable in Wordpress themes. For use in /wp-content/themes/myTheme/functions.php.
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
function add_slug_body_class( $classes ) { | |
global $post; | |
if ( isset( $post ) ) { | |
$classes[] = 'slug-' . $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