Adding attributes to link in wp_nav_menu using custom Walker function

You want to modify the start_el method as you did the start_lvl one. At its most basic it would mean altering this line:

$item_output .= '<a'. $attributes .'>';

To look like this one:

$item_output .= '<a class="dropdown-toggle" data-toggle="dropdown"'. $attributes .'>';

It looks like you will need more complicated logic to avoid inserting that string in all the submenus, but that is the idea.

Leave a Comment

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