Forums
Home / Fixing WordPress / How do you add ID/Classes to wp_page_name list items
(@madastro)
14 years, 4 months ago
I’m using a single sprite for all the links in my menu and here’s my CSS
.nav li a { float:left; height:0; overflow:hidden; width:100px; padding-top:30px; background-image:url(images/nav.png); background-repeat:no-repeat; } .nav .page-item-5 a { background-position:0 0; } .nav .page-item-3 a { background-position:-200px 0; } .nav .page-item-2 a { background-position:-300px 0; } .nav .page-item-5 a:hover { background-position:0 -30px; } .nav .page-item-3 a:hover { background-position:-200px -30px; } .nav .page-item-2 a:hover { background-position:-300px -30px; } .nav .page-item-5 .current_page_item { background-position: 0 -60px; } .nav .page-item-3 a.selected { background-position:-200px -60px; } .nav .page-item-2 a.selected { background-position:-300px -60px; }
the issue with wp_page_menu is the class on the
.nav .page-item-5 .current_page_item { background-position: 0 -60px; }
is there a way to add the current page class to the tag instead? <li class="page-item-5 current_page_item"><a class="selected" ...> or something to that effect?
<li class="page-item-5 current_page_item"><a class="selected" ...>
TIA
(@esmi)
You can’t add classes to the links generated by wp_page_menu. But why don’t you use something like:
.nav .page-item-5 .current_page_item a:hover,.nav .page-item-5 .current_page_item a:active,.nav .page-item-5 .current_page_item a:focus { background-position: 0 -60px; }