Forums

highlight current menu item for section on single page (2 posts)

  1. andy
    Member
    Posted 9 months ago #

    Hi

    I'm building a one-page site, separated into 4 main sections. In the sidebar, I've hard coded an unordered list menu to link to each section. When a user clicks on one of the menu items, and the page scrolls (using Smooth Scroll Links plugin) to the corresponding section, I want to highlight that menu item, but I can't figure out how to assign an ID or class to it.

    I'm using a child theme of Thematic. All the code in one page, and the menu links to the sections using an anchor (ie; #section_title). I tried to assign the ID/class by following this post, but its not working (I assume b/c the is_page function doesn't work on same page anchors).
    http://codex.wordpress.org/Dynamic_Menu_Highlighting

    I've also tried using a custom WP menu, but it assigns current_page_item class to each <li> in the menu. I've searched for hours, but can't find a solution that works.

    Any help would be greatly appreciated - thanks!

  2. Big Bagel
    Member
    Posted 9 months ago #

    The things you've tried won't work because technically all your menu items are pointing to the same page. is_page() checks to see if you're on a page or a specified page; since you only have one page, it always returns true. The only think I can think of is to use onClick and a bit of javascript to change the color. A link would allow for more specific suggestions.

Reply

You must log in to post.

About this Topic