Reputation: 1828
This is my code to load a CSS file in the wordpress backend:
function customAdminStyles() {
$url = get_bloginfo('template_url') . '/wp-admin.css';
echo '<!-- custom admin css -->
<link rel="stylesheet" type="text/css" href="' . $url . '" />
<!-- /end custom adming css -->';
}
add_action('admin_head', 'customAdminStyles');
The problem is that the styles are overwritten by original wordpress CSS declarations, so i have to put a "!important" behind every declaration - i don't like that. Any idea how to load it at last? I don't want to use a plugin.
Upvotes: 2
Views: 233
Reputation: 700
Try this code . This will load admin-style.css in the backend
add_action( 'admin_enqueue_scripts','admin_styles',10 );
function admin_styles() {
wp_register_style( 'custom_admin_css', get_template_directory_uri() . '/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_admin_css' );
}
Upvotes: 2