Extending the WordPress admin_body_class

I’m working on a new WordPress theme for release with 3.0 that includes many new post_types. One problem I found was that if I wanted to not include the editor but allow for photo uploads, the Insert into Post button would no longer appear. But I didn’t want the end user to have access to the editor. So I thought I would remove or hide the editor with CSS or DOM manipulation. One problem I noticed is the admin classes are pretty weak, so I thought to beef it up with a custom class on my post_types.

Here is the snippet to extend the WordPress admin_body_class.

function wpwag_admin_body_class( $classes ) {
	global $wpdb, $post;
	$post_type = get_post_type( $post->ID );
	if ( is_admin() && ( $post_type == 'photo' ) ) {
        $classes .= 'post_type-' . $post_type;
	return $classes;

This will then output on my post_type Photo: post_type-photo. Sweet!

Don’t forget to add the correct filter:

add_filter( 'admin_body_class', 'wpwag_admin_body_class' );