How do I get dashicons to work in a WordPress meta box? I want to do something similar to the calendar icon that is in the “Publish” meta box next to “Published on”.
I have no trouble at all using them as the icon for the custom post type and in the “At a glance” on the dashboard.
This is what I am doing:
#time_control_area #expire:before {
content: "f235";
top: -1px;
}
And this is my result:
I have tried to enque the dashicons styles which has not worked. I cannot find good documentation anywhere on how the dashicons work with WordPress.
Inspecting the back end of one of my sites, the styling for each of the
:before
tags that show the WP-default icons seems to be hard coded intowp-adminload-styles.php
.It looks like you’ll need to manually add
font: 400 20px/1 dashicons;
and possibly some of the other rules to your css to get this to work. Alternately, you could try applying one of the classes WP uses your menu item.Full css I see for the WP-default icons: