Unique WordPress style sheets for Custom Post Type admin screen

Custom post types are an awesome WordPress feature. Anyone designing a website using WordPress that has more than blog posts and pages, should use custom post types. One of the main advantages of this is that you get a clean and focussed admin screen just for that particular asset type. To further enhance this, it would be great if we could specify a specific style sheet just for that post type

Filter to add custom post type editor styles

function tcb_cpt_editor_styles(){
  global $current_screen;
  $css_post_type = 'editor-style-' . $current_screen->post_type . '.css';
add_action( 'admin_head', 'tcb_cpt_editor_styles' );

Using the above code, if you have created a post type ‘cars‘, then you would need the style file ‘editor-style-cars.css‘. If you get a chance to use it, let me know.

Only show your own posts in admin (hiding others’ posts from contributors)

I’ve written some themes and plugins that make extensive use of WordPress custom post types. These are coupled with new roles that lie somewhere between contributor and editor. The member can publish some post types, submit others for review. It has raised the problem that I do not want these members to see other members’¬†posts. The reasons for this are twofold. Firstly the admin screen will get busy, there will be too much noise, this will usually be too complex for them to handle. Secondly I don’t want them looking at other member’s¬†unpublished posts.

The answer is to filter the global $query object, restricting the member to their own posts. This can either be white or black labelled depending on how you wish to go.

 * This restricts posts in wp-admin for Subscribers
 *  and Contributors to their own posts only.
 * However, none of the admin-table-filters hookable into,
 *  so you'll need some CSS too.
add_filter('pre_get_posts', 'tcb_admin_show_only_authors_posts');
function tcb_admin_show_only_authors_posts($query) {
  global $current_user;
  $post_type          = $query->get('post_type');
  $allowed_post_types = array();
  if ( in_array($post_type, $allowed_post_types) ) return $query;

  $restricted_roles = array('subscriber', 'contributor');
  $user_roles = $current_user->roles;
  $role       = reset($user_roles);
  if( $query->is_admin && in_array($role, $restricted_roles) ){
    global $user_ID;
    $query->set('author', $user_ID);
  return $query;

The filter only works for the actual editable content. The (useful) menu across the top allowing people to select mine or published uses some separate SQL, and there are no hooks in the code. So these must be hidden using CSS.

This should get you started:

 display: none;