post_type . '-' . $post->post_name; *//*Un comment this if you want the post_type-post_name body class */ $pagetemplate = get_post_meta( $post->ID, '_wp_page_template', true); $classes[] = sanitize_html_class( str_replace( '.', '-', $pagetemplate ), '' ); $classes[] = $post->post_name; } if (is_page()) { global $post; if ( $post->post_parent ) { # Parent post name/slug $parent = get_post( $post->post_parent ); $classes[] = $parent->post_name; # Parent template name $parent_template = get_post_meta( $parent->ID, '_wp_page_template', true ); if ( !empty($parent_template) ) $classes[] = 'template-'.sanitize_html_class( str_replace( '.', '-', $parent_template ), '' ); } // If we *do* have an ancestors list, process it // http://codex.wordpress.org/Function_Reference/get_post_ancestors if ($parents = get_post_ancestors( $post->ID )) { foreach ( (array)$parents as $parent ) { // As the array contains IDs only, we need to get each page if ( $page = get_page($parent) ) { // Add the current ancestor to the body class array $classes[] = "{$page->post_type}-{$page->post_name}"; } } } // Add the current page to our body class array $classes[] = "{$post->post_type}-{$post->post_name}"; } return $classes; }