Wordpress add page under admin submenu and retaining the active status of the parent submenu page in the menu
I have added a page in the admin menu(pxmag-menu) and a submenu(pxmag-plans). There is another page(pxmag-plans-edit) set under the submenu(pxmag-plans) as the parent page.
public function __construct()
{
require('pxMagAdminPlans.class.php');
$this-admPlanObj= new pxMagAdminPlans();
add_action('admin_menu', array($this, 'add_plan_admin_menu'));
}
public function add_plan_admin_menu()
{
add_menu_page(__('Dashboard', 'textdomain'), get_bloginfo('name'), 'manage_options', 'pxmag-menu', array($this, 'pxmag_dash'), 'dashicons-welcome-view-site', 6);
add_submenu_page('pxmag-menu', __('Subscription Plans', 'textdomain'), 'Plans', 'manage_options', 'pxmag-plans', array($this-admPlanObj, 'plan_admin_menu_page'));
add_submenu_page('pxmag-plans', __('Add/edit Plans', 'textdomain'), 'Add/edit plans', 'manage_options', 'pxmag-plans-edit', array($this-admPlanObj, 'plan_admin_menu_edit'));
}
All the menu and submenu pages load fine.
But, when I open this page(pxmag-plans-edit), the menu selection in the Wordpress admin shows nothing as current item, whereas the pxmag-plans is supposed to be the current selection.
(It is supposed to work like: when I click 'Posts Categories' and subsequently open the 'edit category' page, the 'Posts Categories' option in menu keeps selected).
What is going wrong? What is the correct process?
Topic add-menu-page add-submenu-page admin-menu Wordpress
Category Web