How do I give a WordPress Custom Menu item an id or class for CSS targeting?
I created a custom menu item in Appearance > Menus and would like to be able to specifically target it with CSS; however, I don't know how to assign it an id or c开发者_StackOverflow社区lass? Thanks for the help.
Im not super familiar with the menu creation that way.
But when you create a new page it will automatically get class that points to the page with its ID.
for example:
.page_item .page-item-5
and the last number(s) represents the id of the page. Which you can check from the page edit section in the admin panel.
( edit: it was like five in the morning and i missed that theres actually 2 classes. Regular and specific. Also this is a <li>
tag which contains the <a>
tag
Note that there is also
.current_page_item
which is automatically created.
Try reading the codex, you can pass two parameters to you wp_nav_menu call. One for menu_id and one for menu_class.
As Lollero said above, the menu items themselves will automatically have class's and ID's given to them.
精彩评论