How to use custom CSS in the WordPress admin interface

A bit related to my previous post about using jQuery UI elements in the WordPress admin interface, it’s likely that at some point you want to load your own CSS styles to your plugin or theme’s admin pages.

Lucky for us that’s a lot easier that loading JavaScript! Here’s how – works without adding an action, anywhere outside your main function:

// link some styles to the admin page
$starterstyles = plugins_url ('starter-styles.css', __FILE__);
wp_enqueue_style ('starterstyles', $starterstyles );

Be aware that your CSS will be loaded on every admin page. Since you’ll probably only make minor changes to your own ID’s and classes it’s not a major problem. But if you wanted to you could enqueue styles just like custom JavaScript, as I’ve explained before.

There’s a usage example in the WordPress Codex:
http://codex.wordpress.org/Function_Reference/wp_enqueue_style





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.