I recently had some trouble adding CSS to the back end of WordPress for ONLY the custom post type I was creating. Here is the code I ended up using:
/*
* Adding the admin.css file to the back end of WordPress
*/
add_action('admin_init','load_my_script');
function load_my_script() {
global $pagenow, $typenow;
if (empty($typenow) && !empty($_GET['post'])) {
$post = get_post($_GET['post']);
$typenow = $post->post_type;
}
if (is_admin() && $typenow=='post_type') {
wp_register_style( 'WP_Reports_Admin_Stylesheet', plugins_url('css/admin.css', __FILE__) );
add_action( 'admin_enqueue_scripts', 'wp_reports_admin_styles' );
}
}
function wp_reports_admin_styles() {
wp_enqueue_style( 'WP_Reports_Admin_Stylesheet' );
}
Leave a Reply