Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Created September 11, 2014 00:24
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 joshuadavidnelson/0a5b59be430b5ba76914 to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/0a5b59be430b5ba76914 to your computer and use it in GitHub Desktop.
Add page/post slug to the body class in WordPress
<?php
/**
* Add the post/page slug to the body class
*/
add_filter( 'body_class', 'jdn_slug_body_class' );
function jdn_slug_body_class( $classes ) {
global $post;
$classes[] = $post->post_name;
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment