Skip to main content

Adding a Submenu Custom Link to Custom Post Type WordPress Menu

November 6th, 2017

Recently I had a situation where I wanted to add a submenu item to a custom post type within the WordPress admin that pointed to a completely separate area of the admin where they could find form entries related to that custom post type. That was my particular use case but you could take this route if needing to add any existing URL to a CPT submenu within the WordPress admin.

add_action('admin_menu', 'klf_add_custom_link_into_cpt_menu');
function klf_add_custom_link_into_cpt_menu() {
global $submenu;

// replace this URL with what you want to add
$link = '';

// switch events with your post type slug and Link Title with desired label
$submenu['edit.php?post_type=events'][] = array( 'Link Title', 'manage_options', $link );

The above code would add an external link to my own website within the menu of the events custom post type. You could modify the variables with your desired link location and post type name to append the link to, as needed.

Potential use cases for this would be if you wanted to add a link to another area of the admin — maybe a plugin page or page of form entries — for easier access of site admins. Maybe a third party is integrated for a feature and linking off to them under a related piece is helpful. There are a variety of reasons you may want to make this WordPress admin change.

MORE: WordPress Tutorials

Related Articles