How to Highlight the Current Page in WordPress Navigation Menu

Snippets by IsItWP

Do you want to highlight the current page in navigation or sidebar menu? Highlighting the current page makes navigation easier.

WordPress menu functions (wp_nav_menu, wp_list_pages) automatically add current_page_item class to li containing the active link. So all we have to do is use the same class to highlight the current page.


All you have to do is add this code to your theme’s style.css file:

/* Highlight using list element */

/* Highlight using link element */
li.current_page_item a{

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: Best WordPress Page Builders (Compared).

Comments  Leave a Reply

  1. Work’s fine thanks !

  2. This code works if menu has one tear. Otherwise it highlights first level link and all sub categories in it.
    For example you would be at “home>about>news” and it would highlight all “home” categories instead of just “news”.

  3. My theme adds the CSS class `.current-menu-item`.

    Might be different depending on the theme, but the process is still the same.

  4. works like a charm, and saved me some valuable time. Thanks

  5. Thank you so much!!!!

  6. halo sir, its good but i want to change link color not back ground color plz help me

    1. The color would be controlled by the color property, such as:

      li.current_page_item a{

  7. i think you only need to add this to your CSS and not the functions.php page. It worked just fine in my CSS.

    Thank you

    1. Thanks, the snippet has now been updated.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!