Skip to content

Instantly share code, notes, and snippets.

@younes-dro
Created September 3, 2019 23:02
Show Gist options
  • Save younes-dro/d04ce6ee4ef2e2d28f4f9a9a2edac731 to your computer and use it in GitHub Desktop.
Save younes-dro/d04ce6ee4ef2e2d28f4f9a9a2edac731 to your computer and use it in GitHub Desktop.
Add page slug in body css class
/**
* Add page slug in body class
*
* @global type $post
* @param string $classes
* @return string
*/
//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