Does anyone know of a way to add a unique ID to each submenu wordpress Generates?
As of now, WP generates:
<ul class="sub-menu"></ul>
Ideally, I’d like it to generate
<ul class="sub-menu" id="radio"></ul>
So that I can assign a different style to each sub menu generated via css.
Any help is appreciated.
This would require modifying your theme’s files. Which theme you use will determine how your elements are laid out. I would consider just using the
nth-of-type
css selector to style them.http://jsfiddle.net/yhcYY/
You should also consider asking this on http://wordpress.stackexchange.com which is better at WP theme development questions.
when you are at the WP-Menu editor (Appearance > Menu) you go to the “Screen Options” located at the top upper right and click it and then check the “CSS Classes” option.
Then you will see you can see a new field labeled CSS Classes. There you can add your class for your Menu.
Hope this helps.
This may not be the best way, but it did the trick for me..
It appends the class item-0, item-1, etc to each sub-menu it finds.
The best way to get Uniuqe CSS around your sub menus would be to create a WordPress child theme that uses either the Twenty Ten Theme or Twenty Eleven Theme as your base theme.
Each child theme will inherit all the magical code that the WordPress team has already created to do just what you want.