How to use custom CSS in the WordPress admin interface

- by

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:

If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site witout any pesky ads! More details here.

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.