Web Development Blog

Twitter

26 May, 2009

Highlight the current page link in WordPress

Web Development » CSS, Snippets, WordPress, xHTML » 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.

Other similiar posts that you might be interested in:

3 Responses to "Highlight the current page link in WordPress"

1 | Ber2

June 15th, 2009 at 1:46 pm

Avatar

Great article. Thanks for the sharing.

2 | Sajid Iqbal

June 23rd, 2009 at 6:55 pm

Avatar

Thanks for sharing. It saved me the day.

3 | ???????? ?????? | ???? ??? » ????? ??? 3

July 27th, 2009 at 3:57 pm

Avatar

[...]   Highlight the current page link in WordPress ??? ??? ???? ??? ????? ???? ??? ?????? ???? ?????? ??? ( ???????? , ?? ??? , ??? ?????? , ???? ?? … ) ???? ??????? ?????? ??? ??? ?? ???? ?? ????? ????? ???? ? ?????? ????? [...]

Comment Form


Interests

Web development, Web design, Open source technologies, Portal development, APIs, Web services, Social media applications, Search engine optimisation, Mobile application development, iPhone Apps, Web 2.0, Web 3.0, Latest Internet technologies