Removing Submenu from Menu

You can change nav menu args via the wp_nav_menu_args filter. So let’s say you have a theme that does something like this… <?php wp_nav_menu(array( ‘theme_location’ => ‘second_level’, ‘depth’ => 2, // how many levels to show // prolly some other stuff here )); You can hook into wp_nav_menu_args, check for the theme location, and set … Read more

How to exclude/remove submenu using Walker_Nav_Menu

Filter ‘wp_nav_menu_objects’ would help: add_filter( ‘wp_nav_menu_objects’, ‘remove_sub_items’, 10, 2 ); function remove_sub_items( $items,$args ) { $new_items = array(); for ($i=1;$i<count($items)+1;$i++){ //is lvl0 if(empty($items[$i]->menu_item_parent)){ $new_items= array_merge($new_items, nav_tree($items[$i],$items)); } } // var_dump($new_items); die(); if( $args->theme_location == ‘primary’ ) return $new_items; return $items; } function nav_tree($parent,$items){ $rtn = array(); $rtn[] = $parent; //Edit this conditional, return menu level … Read more

Link to subpages on the same page

get_children is the most straightforward way to get “attachments, revisions, or sub-Pages”. So… $children = get_children(array(‘post_parent’=>$post->ID)); if (!empty($children)) { foreach ($children as $child) { echo ‘<div id=”child-‘.$child->ID.'” >’; // content formatted however you want echo ‘</div>’; } See the Codex page for further parameters that you might need. I don’t know how you’ve constructed your … Read more

How do you add a settings page to another menu?

You’d need to create the top-level menu page, and then the sub-menu after that. Here’s an example: function my_menu() { add_menu_page ( ‘MVC Events’, // $page_title ‘MVC Events’, // $menu_title ‘manage_options’, // $capability ‘mvc-events’, // $menu_slug ‘mvc-options’ // $function ); add_submenu_page ( ‘mvc-events’, // $parent_slug ‘ATB Event Options’, // $page_title ‘ATB Event Options’, // $menu_title … Read more

Remove submenu item from list

Use the API functions remove_menu_page and remove_submenu_page to remove menu items rather than manipulating global variables. This will remove the themes page under appearance: function wpa_remove_themes_submenu() { remove_submenu_page( ‘themes.php’, ‘themes.php’ ); } add_action( ‘admin_menu’, ‘wpa_remove_themes_submenu’, 999 );