Page Slug as Body Class

/*
 * Page Slug as Body Class
 */
function add_slug_to_body_class( $classes ) {
	global $post;
	if ( isset( $post ) ) {
		$classes[] = $post->post_type . '-' . $post->post_name;
	}
	return $classes;
}
add_filter( 'body_class', 'add_slug_to_body_class' );

Leave a Reply

Your email address will not be published. Required fields are marked *