WordPress.org

Ready to get started?Download WordPress

Forums

Anchor links, menu, and highlight current (3 posts)

  1. streettb
    Member
    Posted 3 months ago #

    I'm trying to resolve a problem with anchor (or jump) links in the main wordpress menu.

    If I place a number of jump links to the same page within the menu, it highlights all of the jump links to that page, instead of the one clicked. This is an issue when I navigate to the page with a number of jump links via the menu from another page Is there a workaround to this issue?

    I know this has something to do with the php inserting the current-menu-item class to highlight a link in the menu based on the URL of one's page, but is there a way to filter out current-menu-item class based on the # for the anchor links?

  2. bcworkz
    Member
    Posted 2 months ago #

    Sorry for the slow response, I've been away.

    Yes, you should be able to filter the classes assigned with the 'wp_nav_menu_objects' filter. Examine the passed menu items array structure to determine how to access the assigned classes.

    If you're willing to create or alter a child theme (and not simply do this via plugin), a better approach is to locate the theme's call to wp_nav_menu() and add or overwrite a walker argument. Your walker will have complete control over the HTML created for all menu items, with the ability to apply quite complex logic to how it is created.

  3. bwhall
    Member
    Posted 1 week ago #

    How do I get my anchor links to highlight when they are jumped to? Please help!

    http://wordpress.org/support/topic/highlighting-anchor-page-jumps?replies=1

Reply

You must log in to post.

About this Topic