WordPress.org

Support

Support » Themes and Templates » Custom menu item not getting current-menu-item class added

Custom menu item not getting current-menu-item class added

  • I’m using a modified twentyten theme and want to style the menu item for the currently viewed page different from the rest. I created a menu with a mixture of pages and categories and one custom link for “Home”. All of the items are getting the current-menu-item class applied properly except for the Home link.

    If anyone can tell me what I might need to change, it would be much appreciated.

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • This may be a bug. I’ve discovered it with a default menu widget. .menu-item-home doesn’t also get .current-menu-item when on the page defined in that link.

    Bradford

    @elbradford

    I found on my site that by including the trailing / it worked. However on another site it isn’t working, but that’s maybe because there’s a bunch of stuff following the url. If you’re simply pointing it to your home page include the trailing slash and that might work.

    Adding a trailing slash “/” at the end of the custom menu URL worked for me too.

    seems like you need to use full url with the http://… works for me now.

    @karlevid – Happy to also confirm adding http://… to the start of the custom link prompts WP to add the correct ‘current’ and ‘ancestor’ etc. classes. Thanks!

    I just dealt with this same issue.
    I found that not only did I have to add http://..
    But also the http://www..

    Not sure if the trailing slash was needed or not, but there you go.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom menu item not getting current-menu-item class added’ is closed to new replies.