Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Last active September 6, 2021 15:12
Show Gist options
  • Select an option

  • Save nathaningram/d80c1968a85ea344c613cf4e32cc5053 to your computer and use it in GitHub Desktop.

Select an option

Save nathaningram/d80c1968a85ea344c613cf4e32cc5053 to your computer and use it in GitHub Desktop.
Add Post Slug as Body Class
//Add Page Slug to Body Class
function ni_add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes; }
add_filter( 'body_class', 'ni_add_slug_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment