Support » Plugins » Hacks » filter wp_nav_menu to add current-menu-item for single.php

  • Paul Wright



    With WordPress 3 menus, I’m using wp_nav_menu instead of wp_list_pages. Most of the ‘highlight menu item for single pages’ tricks are built around the old wp_list_pages call.

    I want to make a filter to add ‘current-menu-item’ to the correct menu item on single pages. I looked in wp-includes/nav-menu-template.php: Do I attach to one of these areas:

    $items = apply_filters( 'wp_nav_menu_items', $items, $args );
    $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );

    or is there a better way? Can you point me in the right direction?



Viewing 2 replies - 1 through 2 (of 2 total)
  • I am running through the same situation as we speak. I found this article and is very helpful, this shall definitely become part of the wordpress documentation.

    Improve your WordPress Navigation Menu Output

    Once you have extended the function, you might as well look for the id(or the slug) of the page and add the respective class.

    Hope this helps you as it did help me.


    Iaax Page
    User Experience Design, Web Development and On-Line Marketing Consultant.

    Paul Wright


    Thank you for the reply.

    That looks similar, yes, I’ll have a good look through it soon.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘filter wp_nav_menu to add current-menu-item for single.php’ is closed to new replies.