WordPress: Add custom CSS to admin pages and login page

Last updated on

You can add custom CSS to all admin pages by adding this function to functions.php (located in your theme’s subdirectory in wp-content/themes).

functions.php
function admin_css() { ?>
   <style type="text/css">
      h1 { color: red; }
   </style>
<?php }
add_action('admin_head', 'admin_css');

To add custom CSS to the WordPress login page, add the following to functions.php. This CSS example will override the WordPress logo.

functions.php
function login_css() { ?>
   <style type="text/css">
      .login h1 a { background-image: url(/img/logo.png) !important; }
   </style>
<?php }
add_action( 'login_enqueue_scripts', 'login_css' );

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

Leave a reply

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