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' );
1 Star2 Stars3 Stars4 Stars5 Stars 4.00 (1 votes)

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

p.s. I increased my AdSense revenue by 68% using AI 🤖. Read my Ezoic review to find out how.

Leave a Reply

avatar
  Subscribe  
Notify of