0

I user global $menu in one of my plugins to get the list of menu items. But i would like to get the list of of items from a submenu for example from Posts i would like to get Add new, All, Edit category etc. with slugs or other something unique.

How can i get this?

0

You can use the global variable $submenu.

Example to list the child menu of parent post menu:-

function admin_init_callback() {
    global $submenu;
    $sumenu_list = $submenu['edit.php'];
    var_dump($sumenu_list); //array of submenu
}
add_action('admin_init', 'admin_init_callback', 999);

Profi660 EDIT:
Not needed to be used with admin_init hook.
I used this in my plugin page and worked very well.

Your Answer

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

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