Use WordPress’ built-in dashicons for custom post types

dashicon-library

dashboard-wordpressIf you’ve added some custom post types to your site, but haven’t bothered to go through the process of creating and adding a unique icon for each custom post type, WordPress will use the default “pin” icon and your post types can start to mount up and be indistinguishable from one another.

In WordPress 3.8, while revising the entire admin interface, WordPress introduced “Dashicons“, a new font built especially for WordPress that ships with core. It allows developers and site owners to choose from a range of icons and use them in their plugins and sites.

Since WordPress 3.8, the number of Dashicons has increased and there are now over 200 icons to choose from.

Add a dashicon to a custom post type

First, visit the Dashicons page and choose the icon that you want to use and click on it. At the top of the page, you will now see the dashicon name:

dashicons

You can now use this in your register_post_type() function. Currently your function will either not have an argument for menu_icon, or it will be blank, resulting in the WordPress pin showing up.

All you need to do is add menu_icon as an argument to the function using the dashicon name that you decided upon earlier. That might make your register_post_type function look a bit like this. The important line in this case is line 35:

When you refresh your dashboard, you should now see your new dashicon gracing your CPT menu item:

dashboard-new-dashicon

With over 200 icons available to you, this really allows you to personalise and customise your dashboard so that it’s more user-friendly and intuitive.

Pick out your Dashicons

Leave a Reply