Frank, a reader from UK, asked me how he can highlight the current page. When navigating throught pages, WordPress automatically add a class to the current element, so you can use css to style it as you want.
Frank, a reader from UK, asked me how he can highlight the current page. When navigating throught pages, WordPress automatically add a class to the current element, so you can use css to style it as you want.
The function used to create a list of published pages, wp_list_pages(), automatically add a class current_page_item to the list item corresponding to the page you're viewing.
You just have to add the .current_page_item class to your style.css file:
/* Style the list element */
li.current_page_item{
background:#eee;
color:#777;
}
/* Style the link element */
li.current_page_item a{
text-decoration:underline;
}
9 Responses
Thanks mate!
I’ve always wanted to know how to do this. Thanks for the help.
AAAH ! YES ! Thank you so much !
Not sure why you would want to highlight a page. What would be useful, however, would be the ability to dynamically highlight the latest post. Any clues?
Can we see a copy of the php? If the list is dynamically generated, how do we assign to actual list items?
Thanks for this tip, i’m gonna use it for sure!
Trackbacks: