I am developing my first Wordpress plugin with multiple admin pages. This plugin has a menu and some submenus in Admin Menu. I am using Wordpress 3.9 on XAMPP, Windows 8.1 Pro.


What I want to achieve is like Add New button (link) which is in All Posts page. I mean when one clicks on the Add New link in All Posts page, they are taken to the Add New page itself, with the submenu Add New selected.

enter image description here

Here is my code:

function nes_general_settings_view () { 
    echo "In General Settings";

function nes_vendor_view () { 
    All Vendors <a href="<?=HOW_TO_LINK_TO_nes_vendor_new_view_function?>">Add New Vendor</a>


function nes_vendor_new_view () { 
    echo "In New Vendor";

function nes_tell_us_view () {
    echo "In Tell Us";

add_action("admin_menu", function () {
    "Our Service",   
    "Our Service",           

add_submenu_page( "nes_general_settings", "General Settings", "General Settings", 0, "nes_general_settings", "nes_general_settings_view");

add_submenu_page( "nes_general_settings", "Vendors", "Vendors", 0, "nes_vendor", "nes_vendor_view");
add_submenu_page( "nes_general_settings", "New Vendor", "New Vendor", 0, "nes_vendor_new", "nes_vendor_new_view");

add_submenu_page( "nes_general_settings", "Tell Us", "Tell Us!", 0, "nes_tell_us", "nes_tell_us_view");



How to generate such a link (in particular HOW_TO_LINK_TO_nes_vendor_new_view_function in source code)? Shall I use a special function to generate dynamic contents? And also can you tell me which file generates the All Posts admin page, for the sake of reference?

  • If you've created a CPT this should be automatic. If you are doing something other than that this question is both too broad and too poorly described to answer.
    – s_ha_dum
    May 4, 2014 at 15:28
  • Can you add your code that you are using to add the submenu page you would like to link to? May 4, 2014 at 15:28
  • @Douglas.Sesar: I updated added the source codes and gave more explaination. May 5, 2014 at 4:45
  • @s_ha_dum Can you tell me what does CPT mean? Also I added more explaination to question. May 5, 2014 at 4:50
  • CPT is Custom Post Type May 5, 2014 at 12:30

1 Answer 1


If I understand correctly what you are asking, you need the $menu_slug used when adding your menu pages:

//add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
//add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );

$your_link_url = admin_url( 'admin.php?page='.$menu_slug, 'http' );


$your_link_url = admin_url( 'admin.php?page=nes_vendor_new', 'http' );

You can always verify the link by clicking on the menu item and see where it takes you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.