If you’ve googled the above title like me and came up with a bunch of links on how to enqueue (or load) CSS or JS whilst you are in the admin area, you will have had a ton of stuff related to admin_enqueue_scripts which you don’t want…

The Scenario

You’ve got a lovely website built in WordPress, but there is one problem – when you are logged in and the admin bar is showing the layout goes a little out of whack.

It’s ok you can fix it by loading CSS that only shows whilst the admin bar is on…

// Load CSS for front end admin
function load_custom_wp_admin_style() {
wp_enqueue_style( 'admin-tweaks', get_template_directory_uri() . '/admin-tweaks.css', array(), '1.0.0', 'screen' );

// Only load if admin bar is showing
if ( is_admin_bar_showing() ) {
add_action( 'wp_head', 'load_custom_wp_admin_style' );