1

This question might have been asked already, and if so I apologize but none of the other answers pointed me in the right direction. I am developing my first Wordpress plugin. Lets say it contains the following admin pages:

  • General Settings
  • Add New Vendor
  • Vendors
  • Edit Vendor

Now, I do not want to display the Edit Vendor option in the menu, and I want to make it accessible using a link in Vendors page. My menu and Vendors page are:

enter image description here

Code to generate the menu:

function nes_general_settings_view () { 
    require_once("views/admin/general_settings.php");
}

function nes_vendor_view () { 
    require_once("views/admin/vendor.php");
}

function nes_vendor_new_view () {
    require_once("views/admin/vendor_new.php");
}

function nes_vendor_edit_view () {

    require_once("views/admin/vendor_edit.php");
}

add_action("admin_menu", function () {
    add_menu_page(
        "Service",  
        "Service",  
        "manage_options",            
        "nes_general_settings",      
        "nes_general_settings_view", 
        null,                        
        4                            
    );

    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_fake_id", "Edit Vendor", "Edit Vendor", 0, "nes_vendor_edit", "nes_vendor_edit_view");

});

And Code to generate the link to Edit Vendor page:

<a href="<?=admin_url("admin.php?page=nes_vendor_edit")?>">Edit</a>

But when I am in Edit Vendor page, my menu is not selected.

enter image description here

Now my question is: How do I set the Service > Vendors submenu to the currently selected Admin menu, when I am on the Edit Vendor Page? Please give me an example, since I am really new to WordPress.

migrated from webmasters.stackexchange.com May 5 '14 at 17:04

This question came from our site for pro webmasters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.