How to add custom submenu links in wp-admin menus?

For the custom link into the admin menu, you need to pick up a top-level menu item by its slug and register the function using the admin_menu action hook.

Here is the list of Main Admin Menu slugs.

index.php => Dashboard
edit.php => Posts
upload.php => Media
link-manager.php => Links
edit.php?post_type=page => Pages
edit-comments.php => Comments
themes.php => Appearance
plugins.php => Plugins
users.php => Users
tools.php => Tools
options-general.php => Settings

List of all admin menus and submenus names, keys, and slugs. Image Source

enter image description here

If you want to use the external link then the code is:

add_action('admin_menu', 'add_custom_link_into_appearnace_menu');
function add_custom_link_into_appearnace_menu() {
    global $submenu;
    $permalink = 'http://www.cusomtlink.com';
    $submenu['themes.php'][] = array( 'Custom Link', 'manage_options', $permalink );
}

If you want to render the custom link page using WordPress Administrations Menus functions then the code is:

 add_action('admin_menu', 'add_custom_link_into_appearnace_menu');
 function add_custom_link_into_appearnace_menu() {
    add_theme_page('Custom Link Pgae Title', 'Custom Link Menu Title', 'manage_options', 'custom-link-unique-identifier', 'render_custom_link_page');
 }

 function render_custom_link_page() {
    echo 'Custom Link Page';
 }

Leave a Comment