Adding Your Own Custom Post Type Menu Icons

The latest version of WordPress (3.8) now includes Dashicons, a beautiful set of font icons used on admin screens. And because Dashicons are included on every WordPress admin page you can access them via your own code without doing any additional work!

A nice example use-case for Dashicons is to display unique admin menu icons for CPT’s (custom post types).

When registering a CPT a default icon is used in the admin menu unless you specifically set a different one. The default icon is usually fine but doesn’t really make your CPT stand out. For example say you have registered a testimonial CPT. Here’s how it would look by default in the WordPress admin menu:

Test caption
To use a custom icon you need to set a value for the 'menu_icon' argument when registering a CPT.

/* CPT arguments. */
$args = array(
	'menu_icon' => 'dashicons-format-quote',

/* Register CPT. */
register_post_type( 'my_cpt', $args );

Here, 'dashicons-format-quote' is the Dashicon CSS class name for a double quotes icon. The testimonials CPT icon displayed in the admin menu will now look like this:

To find a particular icon for your own CPT go to the Dashicons website and click on the icon you want. The associated Dashicon class name will be displayed at the top of the page. Copy and paste this into the 'menu_icon' argument when registering your CPT. That’s it!

There is also a full list of Dashicon class names available in WordPress core but for ease-of-use you may prefer the visual method of finding icon class names described above.

About David Gwyer

Founder of WPGO themes and lead developer. I love creating themes that are intuitive and easy to use but deceptively powerful! I also enjoy tinkering around with plugins.

Leave a Reply

Your email address will not be published. Required fields are marked *