Unable to hide all submenus items using foreach construct
-
I made a function to remove certain submenu items in the admin dashboard using
remove_submenu_page
:$submenu = array( 'tools.php' => 'tools.php', // Tools > Available Tools 'options-general.php' => 'options-writing.php', // Settings > Writing 'options-general.php' => 'options-discussion.php' // Settings > Discussion ); foreach ( $submenu as $main => $sub ) { remove_submenu_page( $main, $sub ); }
All of items are hidden except for the Settings > Writing menu. It looks like it has to due with the fact that I am also hidding another submenu under Settings (Settings > Discussion), but I am not sure why it’s being “skipped”.
I could just do the following which would fix this:
remove_submenu_page( 'tools.php', 'tools.php' ); // Tools > Available Tools remove_submenu_page( 'options-general.php', 'options-writing.php' ); // Settings > Writing remove_submenu_page( 'options-general.php', 'options-discussion.php' ); // Settings > Discussion
But I want to use the
foreach
method instead and to understand why this logic isn’t working 100%. Any help is appreciated.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Unable to hide all submenus items using foreach construct’ is closed to new replies.