Custom Icon for Custom Post Type in WordPress

If you have created a custom post type in WordPress then you should customize the icon for your custom post type. As of version 3.8 it’s a easy as adding another parameter to your post type.

  1. Visit http://melchoyce.github.io/dashicons/
  2. Pick desired icon and get name of icon
  3. Add name of dashicon to menu_icon parameter in register_post_type options array
'menu_icon' => 'dashicons-megaphone'

In context it looks like this:

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'experience',
    array(
      'labels' => array(
        'name' => __( 'Experiences' ),
        'singular_name' => __( 'Experience' )
      ),
      'taxonomies' => array( 'category' ),
      'public' => true,
      'has_archive' => true,
      'menu_icon' => 'dashicons-megaphone',
      'supports' => array(
        'title',
        'editor',
        'author',
        'thumbnail',
        'custom-fields',
        'comments',
        'revisions'
      )
    )
  );
}

Published by

MikeGrace

I am a Geek! I hope you enjoyed this recent post.