Option 1: Rely on Dashicon Icon Library used in WordPress Dashboard
You can peruse the plethora of options here. Once you’ve found an icon you like, simply set the ‘menu_icon’ to the class associated with the icon you’ve found, like so: register_post_type( 'team', array( 'public' => true, 'menu_icon' => 'dashicons-groups', 'label' => 'Team', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) );
Option 2: Use an image you’ve uploaded to a static url
You can do this simply by dropping in the static url of your uploaded image: register_post_type( 'team', array( 'public' => true, 'menu_icon' => 'http://www.my-site.com/images/team-icon.png', 'label' => 'Team', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) );
Option 3: Use a local file path so your icon doesn’t break once you’ve migrated your dev site to a live server
register_post_type( 'team', array( 'public' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/images/team-icon.png', 'label' => 'Team', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) );
Reference here
Leave a Reply