How to Add an Icon to a WordPress Plugin’s Custom Menu Page

Quick Summary

  • Pass a Dashicon class name, such as dashicons-welcome-widgets-menus, as the sixth argument of add_menu_page() inside an admin_menu callback.
  • For a custom logo, pass an image URL built with plugins_url() and __FILE__, using a small square image shown at 20 by 20 pixels.
  • Pass the function that prints your page as the fifth argument, because the examples leave it empty and the page stays blank.

When your plugin adds its own page to the WordPress admin with add_menu_page(), the sixth argument decides which icon appears next to it in the sidebar. You can use one of the Dashicons that ship with WordPress, or point to your own image. Here are both methods.

Add the code to your plugin’s main file (or your theme’s functions.php while testing). The admin_menu hook makes sure the page is registered when WordPress builds the admin menu.

Method 1: use a Dashicon as the add_menu_page icon

Dashicons are the icon font built into the WordPress admin, so there is nothing to upload. Custom post types take the same names in their menu_icon argument, as in registering a custom post type. Pass the icon’s class name as the sixth argument – here dashicons-welcome-widgets-menus. You can find every available name in the Dashicons reference. A Dashicon also follows the user’s admin color scheme automatically.

PHP
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page() {
  // add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
  add_menu_page( 'Custom Menu Page Title', 'Custom Menu Page', 'manage_options', 'custom.php', '', 'dashicons-welcome-widgets-menus', 90 );
}
  • manage_options means only administrators see the menu item.
  • 90 is the position: it places the item below Settings. Leave it out to add the item at the bottom.
  • The fifth argument is empty here. In a real plugin, pass the name of the function that prints your page, otherwise the page stays blank.

Method 2: use your own image

To use a custom icon, pass the URL of an image instead of a Dashicon name. plugins_url() builds that URL for a file inside your plugin folder, so it keeps working wherever the site is installed.

PHP
/**
 * Register a custom menu page.
 */
function wpdocs_register_my_custom_menu_page() {
    add_menu_page(
        __( 'Custom Menu Title', 'textdomain' ),
        'custom menu',
        'manage_options',
        'myplugin/myplugin-admin.php',
        '',
        plugins_url( 'myplugin/images/icon.png' ),
        6
    );
}
add_action( 'admin_menu', 'wpdocs_register_my_custom_menu_page' );
  • Use a small, square image: the admin menu shows icons at 20 × 20 pixels.
  • __() makes the page title translatable; replace textdomain with your plugin’s text domain.
  • 6 places the item near the top, just below Posts.
  • From your plugin’s main file, plugins_url( 'images/icon.png', __FILE__ ) is the safer form: it doesn’t depend on the plugin folder’s name.

Which add_menu_page icon should you use?

Use a Dashicon when one of them fits your plugin – it’s the quickest option and matches the rest of the admin. Use your own image when you need your brand’s logo in the menu.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More