WordPress: adds the post type and slug to the class, e.g., "page-about"
<?php
/**
* Adds the post type and slug to the <body> class, e.g., "page-about".
*/
add_filter( 'body_class', function( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[]= "{$post->post_type}-{$post->post_name}";
}
return $classes;
});