26 May, 2009
Highlight the current page link in WordPress
If you are hard-coding your navigation menu in WordPress rather than using wp_list_pages() template tag, you will need to add a class manually in order to highlight the current page it is on.
<li<?php if (is_page('gallery')) : echo ' class="current_page_item"'; endif; ?>><a href="gallery/">Gallery</a></li>
Note: wp_list_pages() template tag automatically add current_page_item class to the <li> element for the currently viewed page.
Love what you've just read? Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
Other similar posts that you might be interested in:
- 5 steps to creating a custom Archive page in WordPress
- Display 5 latest posts in each category in WordPress
- Customising category.php in WordPress
- Internet Explorer 8 (beta) is here
- Top 10 jQuery Mobile Code Snippets that you need to know
- Common elements on magazine websites
- Display 10 recent post titles on homepage
Hello! Welcome to Web development blog! My name is Ei Sabai and on this blog, I write about web development, mobile app development, latest web technologies and the likes. Read more 


Great article. Thanks for the sharing.
Thanks for sharing. It saved me the day.
[...] Highlight the current page link in WordPress ??? ??? ???? ??? ????? ???? ??? ?????? ???? ?????? ??? ( ???????? , ?? ??? , ??? ?????? , ???? ?? … ) ???? ??????? ?????? ??? ??? ?? ???? ?? ????? ????? ???? ? ?????? ????? [...]
thnx for the article, i’ve tried to find this all over the internet but i couldn’t find proper solution!
Thanks once more