1

Let's say we have a site with four items in a managed menu, corresponding to pages:

Home | Foo | Bar | Baz

The "Home" item is a custom link pointing at "/".
And we want the "Bar" content shown on the home page, so in Settings, we specify that for the front page.

When visiting the homepage, both "Home" and "Bar" get active classes, resulting in styling(.current-menu-item / .current_page_item) like:

Home | Foo | Bar | Baz

…when it seems reasonable to expect that only Home be highlighted.

Did I do something wrong here, or is this actually buggy(or at least sub-optimal) behavior? And is there a relatively painless way to correct it in templating? I can undo the styling pretty easily with a bit of page-targeted CSS, but it's a workaround to the actual problem and I'm curious if there's something I'm missing in the theming.

1 Answer 1

1

This is actually intended and accurate behaviour, it just isn't desired for your specific use case.

To put it another way, when you click on bar, by your logic home should not be active, but it will be, because home and bar are the same page, with the same URL. Thus what you want is ambiguous.

Instead I recommend you download and install the Spots plugin. Create a new Spot with the content from the bar page, then insert that spot into the bar page. Finally, create a page called Home, and set that as the frontpage, and hey presto, home != bar and the menu works as desired, but they both show the desired content.

3
  • Oh, crap. I somehow kept glossing that it does reassign the URL for the home-specified page. I'm not sure Spots will work here(the content is an involved Flexible Content setup from Advanced Custom Fields, and the selected page may even change from time to time) but thanks for the recommendation; it's a tool I'd like to have around for other uses anyway.
    – Su'
    Sep 20, 2012 at 19:40
  • argh link has been suspended
    – Tom J Nowell
    Sep 20, 2012 at 21:19
  • thanks for the upvote though, Ill take a look at flex content if it ever loads. Another thing you could try that would be very hackish is to override the styles if the body tag has the .home css class , but that's just plain evil
    – Tom J Nowell
    Sep 20, 2012 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.