The following code snippet registers a new custom post type called Books in WordPress. A unique Dashicon (dashicons-book) is assigned to this post type in the WordPress admin menu for easy identification.
function ts_custom_post_type_with_dashicon() {
$args = array(
'labels' => array(
'name' => 'Books',
'singular_name' => 'Book'
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-book', // Using Dashicon for the custom post type
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('book', $args);
}
add_action('init', 'ts_custom_post_type_with_dashicon');