Hi,
I was having the same issue. After looking around a bunch, this is what I came up with that works: You need to create a private variable outside your functions. I used the item’s ID instead of name.
class My_Walker_Nav_Menu extends Walker_Nav_Menu {
private $curItemID;
function start_lvl(&$output, $depth=0, $args = array() ) {
$itemID = $this->curItemID;
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul id=\"dropdown".esc_attr($itemID)."\" class=\"sub-menu\" >\n";
}
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 )
{
global $wp_query, $wpdb;
$this->curItemID = $item->ID;
...
I hope this helps!