Skip to content

Instantly share code, notes, and snippets.

@vc27
Created October 25, 2011 17:28
Show Gist options
  • Save vc27/1313579 to your computer and use it in GitHub Desktop.
Save vc27/1313579 to your computer and use it in GitHub Desktop.
Add a post_type class to the admin body element. Helpful when styling custom post types.
/**
* Filter Admin body class
*
* Add a post_type class to the admin body element. Helpful when styling custom post types.
**/
add_filter( 'admin_body_class', 'vc_admin_body_class' );
function vc_admin_body_class( $admin_body_class ) {
global $post;
if ( $_GET['post_type'] )
$post_type = $_GET['post_type'];
elseif ( $post->post_type )
$post_type = $post->post_type;
if ( $post_type )
$admin_body_class = "$admin_body_class post_type-$post_type";
return $admin_body_class;
} // end function vc_admin_body_class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment