1

Will someone please show me how to change the color of one dashicon on the wordpress admin toolbar? When I change the color in browser inspector, the color changes, but when I add it to my style sheet, it does not work no matter how specific I make it.

#adminmenu .current div.wp-menu-image::before, #adminmenu .wp-has-current-submenu div.wp-menu-image::before, #adminmenu a.current:hover             div.wp-menu-image::before, #adminmenu a.wp-has-current-submenu:hover div.wp-menu-image::before, #adminmenu li.wp-has-current-submenu a:focus        div.wp-menu-image::before, #adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image::before, #adminmenu li.wp-has-current-submenu:hover       div.wp-menu-image::before {
color: #e74b4b;
} 
vlasits
  • 2,215
  • 1
  • 15
  • 27
cboy
  • 169
  • 2
  • 3
  • 13
  • 1
    I'm very curious to learn why would you want to do that? Anyway, the stylesheet you are adding it to is most likely one only loaded for frontend pages, and so will never apply to anything in the backend - different stylesheets are used to style your wordpress dashboard - core files that you shouldn't be editing. – UncaughtTypeError Nov 03 '17 at 19:55
  • I have built a site for my mother using custom post types and custom fields. I would like to change the color of the dashicon to stand out from the other options. I am using a child theme. – cboy Nov 04 '17 at 00:53

2 Answers2

1

Most likely you are putting your css into the wrong css file. The admin section doesn't load the standard 'style.css' file.

You will want to add your admin styles to a separate file like my_admin_styles.css or something within your theme and then include it with the admin_enqueue_scripts() function. Or, if you don't have access to editing the functions.php file, you may need use a plugin as the commenter below mentions.

vlasits
  • 2,215
  • 1
  • 15
  • 27
  • 1
    There's a plugin for adding to backend style sheets at https://wordpress.org/plugins/style-admin/ Might come in handy; at any rate it's better than munging core WordPress code. – O. Jones Nov 03 '17 at 20:18
  • 1
    Definitely better than editing core, but overkill if you are building your own theme or otherwise have access to the theme files. It's literally one line of code. – vlasits Nov 03 '17 at 20:21
0

Thank you all for your replies which led me to the correct answer that made it work for me. You would use this if you are using a child theme.

function my_admin_theme_style() {
    wp_enqueue_style('my-admin-style', get_stylesheet_directory_uri() . '/admin_style.css');
}
add_action('admin_enqueue_scripts', 'my_admin_theme_style');
cboy
  • 169
  • 2
  • 3
  • 13