in wordpress, I am fetching menu using wp_nav_menu()
function. It will list menus in following form.
<ul>
<li><a href="url">AA</a></li>
<li><a href="url">BB</a></li>
<li><a href="url">CC</a></li>
</ul>
I want to add one more property to tag. I want it in following form.
<a href="url" name="aa">AA</li>
<a href="url" name="bb">BB</li>
<a href="url" name="cc">CC</li>
name
property should have value equal to link text but in lower case. i.e. is menu text is AA then name
property should have aa
You can do this with WordPress Walkers. They can be a bit tricky at first, but very powerful. This is a rough implementation, you would probably need to improve it.
First, you extend the Walker_Nav_Menu to your needs:
Then you pass an instance of your class to wp_nav_menu:
This will output menu elements like this: