Generate a Menu that displays all child pages of top level parent

I used this answer’s code to generate a widget that displays all subpages of the parent’s page: if (is_page()) { global $wp_query; if( empty($wp_query->post->post_parent) ) { $parent = $wp_query->post->ID; } else { $parent = $wp_query->post->post_parent; } if(wp_list_pages(“title_li=&child_of=$parent&echo=0” )) { wp_list_pages(“title_li=&child_of=$parent&echo=1” ); } } I now realise this does not cope if I am in a … Read more

Adding different classes to anchor in navigation menu

Is this possible? I want to add different classes to the anchors, so not the same on all anchors. How can I do this? PS: I am using this: function add_nav_class($output) { $output= preg_replace(‘/<a/’, ‘<a class=”your-class”‘, $output, 1); return $output; } add_filter(‘wp_nav_menu’, ‘add_nav_class’); But I want to add different classes to the links… So like … Read more

Check if wp_nav_menu items have submenus

I’m looking to output the following markup for a menu through wp_nav_menu, <ul> <li><a href=”https://wordpress.stackexchange.com/”>Home</a></li> <li> <a href=”https://wordpress.stackexchange.com/” aria-haspopup=”true”>Blog</a> <ul> <li><a href=”https://wordpress.stackexchange.com/”>Design</a></li> <li><a href=”https://wordpress.stackexchange.com/”>HTML</a></li> <li><a href=”https://wordpress.stackexchange.com/”>CSS</a></li> <li><a href=”https://wordpress.stackexchange.com/”>JavaScript</a></li> </ul> </li> </ul> The menu items may have submenus – if that’s the case the top level link needs to be formatted as the example above. I’ve … Read more

Generate a tabbed submenu — from taxonomy term or submenu item — with sample content

I’m looking to generate a tabbed submenu from taxonomy term or submenu item and include sample content (three items per term/submenuu item). The styling I can do, the problem is the html generation. I see this style called tabbed submenus, fat menus, or mega menus. A good sample is the tabbed submenus at Vice.com. The … Read more

Add div to specific sub-menu

I researched in google, yandex but had no success. With this code I can set a div to sub-menu but this code add to all sub-menus, I just need to add div to specific sub-menu. class Megratron_div extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); … Read more