tags:

views:

274

answers:

4

How can I highlight the current WP page using this code:

<div id="menu">
    <ul>
     <li>
      <?php wp_list_pages('title_li=&depth=1&exclude=52'); ?>
     </li>
    </ul>
</div>
+2  A: 

Found in the (huge) documentation for wp_list_pages():

All list items (li) generated by wp_list_pages() are marked with the class page_item. When wp_list_pages() is called while displaying a Page, the list item for that Page is given the additional class current_page_item.

So use the current_page_item class.

Ölbaum
(BTW, my answer is not meant to sound like RTFM.)
Ölbaum
A: 

Yeah I tried that, but it's not working. Which led me to believe maybe I should use some code?

HollerTrain
You just might have the selectors wrong in the CSS that targets it. Olbaum's answer should square it away.
Gipetto
A: 

You can try and pass it the echo=0 parameter. It should return the HTML instead of printing it and you can process it to find the current page, apply the class and print the result. Not very clean, but if the normal behaviour doesn't work, it gives you a workaround.

Ölbaum
A: 

The CSS needed; change color to whatever you want:

#menu ul li a:active, #menu ul li.current_page_item a
{
color:#000;
}
songdogtech