Output the aria-labelledby parameter for a nav menu child

I solved it. I thought it could work but i wasn’t sure, and i wanted some opinion from more experienced people. Anyways, this is what i have done:

First of all, i defined a private var in my walker class:

private $el;

In my start_el() function, i filled this var with $item

$this->el = $item;

At this point, i was able to access any item’s property from start_lvl()

$output .= "{$n}{$indent}<ul class=\"dropdown-menu\" aria-labelledby=\"link-".$this->el->ID."\">{$n}";

Oh well, that was simple, but i hope i’ll help someone

Leave a Comment