Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I create a custom post type with a unique admin menu icon?
Asked on Feb 13, 2026
Answer
Creating a custom post type in WordPress allows you to organize content beyond the default posts and pages. You can also customize the admin menu icon for your custom post type to make it visually distinct.
<!-- BEGIN COPY / PASTE -->
function my_custom_post_type() {
$labels = array(
'name' => 'Books',
'singular_name' => 'Book',
'menu_name' => 'Books',
'name_admin_bar' => 'Book',
'add_new' => 'Add New',
'add_new_item' => 'Add New Book',
'new_item' => 'New Book',
'edit_item' => 'Edit Book',
'view_item' => 'View Book',
'all_items' => 'All Books',
'search_items' => 'Search Books',
'not_found' => 'No books found.',
'not_found_in_trash' => 'No books found in Trash.'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'book'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => 'dashicons-book', // Custom icon
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')
);
register_post_type('book', $args);
}
add_action('init', 'my_custom_post_type');
<!-- END COPY / PASTE -->Additional Comment:
- Replace 'dashicons-book' with any Dashicons class name to change the icon.
- Ensure the function is hooked to 'init' to register the post type correctly.
- Visit the Dashicons page in the WordPress developer resources to find available icons.
- Custom post types can be managed under the "Books" menu in the WordPress admin after registration.
Recommended Links:
