How to add a custom icon to your custom post type

Here’s a quick way to add custom icon to your new custom post type’s menu item. It will replace the default pushpin image that your post type uses by default.

Before you paste the following code into your theme’s functions.php file, you’ll have to change two things:

  1. Replace the $icon_url value with the source to your custom image icon.
  2. Then change product in #menu-product to the actual name (not label) of your custom post type.
add_action( 'admin_head', 'my_custom_posttype_icon' );
function my_custom_posttype_icon() {
    $icon_url = esc_url( admin_url( 'images/generic.png' ) );
    <style type="text/css" media="screen">
        #menu-product .wp-menu-image {
            background: url(<?php echo $icon_url; ?>) no-repeat 6px !important;

Note: WordPress 3.0 will have a menu_icon parameter for the register_post_type() function.
This is just a quick workaround for the beta release.

#functions, #icon, #post-type