Take the 2-minute tour ×

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

<div id="menu">
    		<?php wp_list_pages('title_li=&depth=1&exclude=52'); ?>
share|improve this question
add comment

migrated from superuser.com Sep 1 '09 at 20:44


3 Answers

The CSS needed; change color to whatever you want:

#menu ul li a:active, #menu ul li.current_page_item a
share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
(BTW, my answer is not meant to sound like RTFM.) –  Olivier 'Ölbaum' Scherler Sep 1 '09 at 20:55
add comment

Your Answer

