[Snippet] [WP] "Feature" Fix: Admin Theme on Front End

In continuing with my last post on “Quickly Telling Which Environment You’re In”, this snippet will fix an annoying, long standing “feature” of WordPress: not transferring your admin theme to the front end.

To fix it, simply pop this snippet anywhere in your functions.php:

# Admin theme on front end
add_action('wp_enqueue_scripts', function(){
        $theme = get_user_meta(get_current_user_id(), 'admin_color', true);
        wp_enqueue_style('custom-colors', wp_admin_css_uri("css/colors/$theme/colors.min"));

32px doesn’t sound like much but with careful color selection, you can create a seamless fixed header that merges with your current one…whether you’re logged in or not.


Bonus: Go a step further and white label the userbar. Remove the WordPress logo with this (again drop it into functions.php):

# Remove the WordPress Logo
add_action('wp_before_admin_bar_render', function(){
    global $wp_admin_bar;

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.