Adding a Custom Post Type icon the right way

Remi | July 18, 2012 | in Custom Post Types

I think that now, nearly every WordPress developer knows how to create a custom post type (if you don’t, just download Easy Custom Post Type, a great plugin by the amazing Pippin Williamson), so i’m not going to explain how to create a custom post type, but i’m going to show you how to properly add a custom post type icon in the administration menu. The good point with this method is that you’ll get the really nice “mouse over” effect that renders the images from grey to colors.

If for example you create a custom post type called “portfolio”, here is the code to use to properly display the icon. This code must be placed in your functions.php inside your theme folder or in any page of your plugin (if you use this code in a plugin you will have to update the image path). Don’t forget to update the code depending on your custom post type attributes:

You can download here an image sample that fits the provided code.

The author

About the author Remi: Hey! My name is Rémi Corson, i'm a WordPress Expert Developer, i create high level themes and plugins, and i provide free stuff every week on this website!


Leave a reply