Modify sub_menu function to show pages below a specifically set page
To specifically target a page and show its children/siblings you can use wp_list_pages(); eg. wp_list_pages(array( ‘child_of’ => “page parent ID”, ‘depth’ => 2 ));
To specifically target a page and show its children/siblings you can use wp_list_pages(); eg. wp_list_pages(array( ‘child_of’ => “page parent ID”, ‘depth’ => 2 ));
I solved it using ‘menu_order’: function parent_menu_order($post) { if( isset($post->post_parent) ) { if($post->post_parent == 0) { return $post->menu_order; }// if no parent, return it itself $post_data = get_post($post->post_parent); return $post_data->menu_order; } else { return -1; } }
As I said, I’ve been missing a stupid detail in my CSS, there was a fixed height for all the li. Problem solved by removing it.
In your array, have you tried setting depth to 0 or 2? wp_nav_menu( array( ‘theme_location’ => ‘header-menu’, ‘container_class’ => ‘navigator’, ‘depth’ => 2) ) Where 0 should be the default and allow unlimited submenu, and 2 would allow one submenu. I am not sure how this would happen, but if it works, perhaps somewhere the … Read more
wp_nav_menu displays the menu created in the Appearences > Menu section of wordpress admin area. That is where you can “print the menu with correct children names”. Unless there is some other code in your functions that is messing with the wp_nav_menu function.
When using wp_nav_menu you can pass arguments to it which help you style the output, look at: $container Whether to wrap the ul, and what to wrap it with. Allowed tags are div and nav. Use false for no container e.g. container => false . $container_class the class that is applied to the container. $container_id … Read more
Figured it out! Use the following PHP code. /* * Toggles the menu dropdowns to open state */ function mod_toggle_menus() { ?> <script type=”text/javascript”> jQuery(document).ready( function() { /* add toggled-on class to submenus */ jQuery(‘.sub-menu’).addClass(‘toggled-on’); }); </script> <?php } add_action(‘wp_footer’ , ‘mod_toggle_menus’);
So this is the way I eventually achieved this. I put the following code into my functions.php (actually into the functions.php of my child theme to keep it safe from updates) It has just one change to the original code from the link in the question thanks to @birgire. /** * auto_child_page_menu * * class … Read more
Has there been any improvements to wp’s menu handling?
Problem with sub-menu container