Navigation menu with children shown only for current page

If you dont mind using a plugin I can tell you how I have gotten this to work in the past. Add the following code to your functions.php function get_root_parent($page_id) { global $wpdb; $parent = $wpdb->get_var(“SELECT post_parent FROM $wpdb->posts WHERE post_type=”page” AND ID = ‘$page_id'”); if ($parent == 0) return $page_id; else return get_root_parent($parent); } … Read more

Set Item Order with wp_nav_menu_{$menu->slug}_items

you can always search & replace by string or regex the output html of the filtered $items. anyway, if you’re targeting usual menu items, you can add $post objects and order items through the wp_nav_menu_objects filter, otherwise here’s the basic sample code: function replace_itemcart_in_menu( $items, $args ) { $url = home_url(‘my-item’); $previtem = ‘<li id=”menu-item-11″ … Read more

Wrap description and sub menu in a wrapper

Ended up doing via jquery jQuery(‘.menu-item-has-children’).each(function(){ idLi=jQuery(this).attr(‘id’); jQuery(‘#’+idLi+’ ul’).wrapAll(‘<div class=”slideFromtop”>’) });

Add div to specific sub-menu

The WordPress native Walker class doesn’t pass the arguments you need to the start_lvl() method. So to do this, you will need to add a custom display_element() method to your custom walker. You can use most of the original, with something similar to the commented section below: public function display_element( $element, &$children_elements, $max_depth, $depth, $args, … Read more

Add Menu items description via Custom Walker for wp_nav_menu()?

I have used custom nav walker for showing descriptions in one of my project. i am sharing the code here so it might help you to solve your issue. class annframe_description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( “\t”, $depth ) : ”; $class_names … Read more

Anchor only wp_nav_menu

You already mentioned in your question that u had removed li from the menu. so may be this will work. in this walker u can give the class in the Appearance ->menu css options (On the top right of the screen click on ‘Screen Options’ on the bottom row – make sure ‘CSS Classes’ is … Read more