Wordpress Snippets

How to Add CSS Styles to WordPress Admin

WordPress has obviously grown from a personal blogging tool to a collaborative blogging environment with multiple authors and multiple blogs in a network with the WordPress multisite.

This sometimes call for styling not only your front end for your visitors, but also the backend of your WordPress admin.

To add admin styles to make some tweaks here and there, like hiding some stuff using display:none or something of that sort, here is what you need to do.

Add the following snippet into the functions.php of your active theme:

/** 
* Add CSS to WordPress Admin
* 
* @refer https://millionclues.com?p=2989
*/
function load_custom_admin_css() {
  
  wp_enqueue_style('my_custom_admin_css', WP_CONTENT_URL . '/themes/custom_admin.css');
}
add_action( 'admin_enqueue_scripts', 'load_custom_admin_css' );

Now create a custom_admin.css in your wp-content/themes/ folder and add all the custom css you want in there.

For instance, to hide the Plugins section from the Admin sidebar, you would add to your custom_admin.css:

#menu-plugins {
  display:none !important;
}

Of course, like all things CSS, this is a cosmetic change. The plugins area would still be accessible via a direct link. If you wish to remove them or show them based on user-role, Admin Menu Editor can do that for you.

Have fun. Out.

Update: If you want this to be theme independent, I have a cute plugin for you: Admin CSS MU. Check it out.

Hire Us. Or just say Hi!
Need a job? Apply to get one.