How to Add Custom CSS to Admin Area

Last modified Jul 18, 2023
Difficulty Intermediate
Language CSS, PHP
Category

You can stylize the dashboard admin area with the custom CSS. Here is the snippet code you need to paste into functions.php file. Replace the comment with your custom code.

“admin_head is an action event and can be hooked by add_action hook. The action refers on the admin area and everything you include here will be applied only on the admin side. ”

More information

 

PHP

add_action('admin_head', 'my_custom_acode');

function my_custom_acode() {
  echo '<style>
   /* your code here */
  </style>';
}

 

Does this snippet (still) work?

Please let us know in the comments if everything worked as expected. We have tested this code with the Version: 4.0.1 of the Divi Theme and Divi Friendly Hosting with PHP 7.3 and WordPress 5.2.4.
If you think this code saved you time, we will be happy to receive a comment! ?

____

License: This snippet is from https://codex.wordpress.org, copyright WordPress,  Licensed under the GNU General Public License, no warranty; click here for details.

Your Comments

3 Comments

  1. Baseerdeen Mohamed Umar

    It works perfectly. Thank you

    Reply
  2. Kessy

    Hi,
    It works perfectly. I opted to separate it and put it in an external file and use wp_enqueue_style() for better future maintenances.
    J

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Next snippet Hide Any Plugin from the WordPress Dashboard
Previous snippet Make Divi 4.0 Header Sticky or Fixed on the Scroll