Create self-populating menu and add extra divs to the menu layout

Your html structure should look like <ul class=”parent-class”> <li>Page 1</li> <li> <ul class=”child-class”> <li> Sub menu item 1</li> <li> Sub menu item 2</li> </ul> </li> </ul> WordPress should automatically add an “active” class to the active page then you should be able to style everything with css. Something like .parent-class li ul { Display:none; } … Read more

Menu location by menu id or menu ID in start_el() Walker

You’ll find it much easier to control which fields are shown, by controlling which walker is used. Rather than trying to ‘toggle’ the fields inside the walker. I also wanted to show a bunch of custom fields, and only show them on a menu at a particular menu location. So I used the following… add_filter( … Read more

Custom Nav Walker to show siblings and children of current branch?

Well, as much as I prefer to have my own walker and control over the nav, I found a plugin that does exactly what I want: Advanced Menu Widget http://wordpress.org/extend/plugins/advanced-menu-widget/ Only tested slightly but its working just as I expected, just have to select “Only strictly related sub-menu” in the menu widget config. I should … Read more

Check what “type” a menu item is

Fortunately, there is an easy fix for this. The $item in the Walker delivers Classes, and if the menu item is an archive, you get one of those: menu-item-type-taxonomy (general) menu-item-object-product_cat (product_cat == taxonomyname) as well as $item->type == ‘taxonomy’ $item->object == ‘your_taxonomy’ If you want this logic to work for various Archives (not just … Read more

Benefits of using Nav Walker?

I would say mostly you see the usage of wp_nav_menu(), which does use wp_get_nav_menu_items(). You can use wp_nav_menu() with the default walker or a custom walker. To be honest I can’t remember the time I did a menu manually, with wp_get_nav_menu_items() or something else, and I tend to be lazy, so this is definitely more … Read more

how to conditionally add attributes to start_lvl() function?

You don’t have the data you need in the start_lvl() method to do this. That data is available in the start_el() method in the $item variable, so you will have to cook up a way to pass that data along: class my_extended_walker extends Walker_Nav_Menu { var $prnt = 0; var $pdepth = false; public function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)