Page Slug in body class

Page Slug in body class

WordPress
Amitpal Singh

Put this in your theme functions.php

[php]
//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’ );
[/php]

You can see this in Inspect Element below: