Adding a Dashicon to a Custom Post Type in WordPress

Once you have Custom Post Types set up and available via the WordPress Dashboard you can assign a Dashicon to them , these are the icons fonts already loaded and in use in the WordPress Dashboard.

Selection of the icon can be done here.

dashicon-selection

So in the above example, I have chosen the person icon whose corresponding name is dashicons-admin-users

In your Custom Post Type arguments array add this value to menu_icon

add_action( 'init', 'pp_create_custom_post_type' );

function pp_create_custom_post_type() {

	$labels = array(
		'name' => __( 'Coach and Mentors' ),
		'singular_name' => __( 'Coach and Mentor' ),
		'all_items' => __('All Coach and Mentor'),
		'add_new' => _x('Add new Coach and Mentor', 'Coach and Mentor'),
		'add_new_item' => __('Add new Coach and Mentor'),
		'edit_item' => __('Edit Coach and Mentor'),
		'new_item' => __('New Coach and Mentor'),
		'view_item' => __('View Coach and Mentor'),
		'search_items' => __('Search in Coach and Mentor'),
		'not_found' =>  __('No Coach and Mentor found'),
		'not_found_in_trash' => __('No Coach and Mentor found in trash'),
		'parent_item_colon' => ''
	);

	$args = array (
		'labels' => $labels,
		'public' => true,
		'has_archive' => true,
		'menu_icon' => 'dashicons-admin-users',
		'rewrite' => array('slug' => 'coach-mentor'),
		'taxonomies' => array( 'category', 'post_tag' ),
		'query_var' => true,
		'menu_position' => 5,
		'supports'	=> array( 'genesis-cpt-archives-settings', 'thumbnail' , 'custom-fields', 'excerpt', 'comments', 'title', 'editor' )

	);

	register_post_type( 'coach_mentor',$args);
}

dashicon-custom-post-type

And this will appear in the backend.

Additional Info

Creating Custom Post Types and re-positioning them in the menu – Gist Ref.

Leave all Comment