0

I'm using the WordPress Astra theme. I have set Astra customization to highlight the active page primary menu item in the navigation bar. However, when I link to the "Contact" page using an appended query string to pre-populate the contact message field, the "Contact" menu item in the navigation bar fails to highlight. Any suggestions for custom css to correct this? I don't think it matters, but I'm using the Forminator plugin for the form.

Example: see the difference between these two links to the Contact page. In the first example the "Contact" menu item is highlighted. The second does not.

https://poweremf.com/contact/
https://poweremf.com/contact/?query_text=Hello

2
  • 1
    instead of using the "custom links" element in the menu, use a "page" element.
    – mmm
    Commented Sep 20 at 20:25
  • Thank you for the response. This is actually the way I originally had it, but the Word Press SEO optimizer suggested that one-word titles would be much less likely to show up in online searches. Consequently, I moved to custom links for the nav menu so I could have longer, but not visible, titles to satisfy SEO.
    – JLEM
    Commented Sep 24 at 12:58

1 Answer 1

1

I checked both of your links and in the <body> tag, both of them have class page-id-1508, meaning that the page id is recognised correctly either with or without the query variable.

However, as @mmm suggested in the comment above, it seems that you added the menu item as Custom Link (note the menu item classes menu-item-type-custom menu-item-object-custom; if you added it as a Page, it would has classes menu-item-type-post_type menu-item-object-page).

Since it is a Custom Link, when the link changes (in this case, it has query variable added), WordPress doesn't recognise it as the same link anymore, and thus it looses the active class.

So because that is a page, I suggest you add that menu item as a page and check again.

1
  • 1
    Thanks for taking the time to look at the page. As commented to mmm, I originally used the page approach, but changed to custom links for the nav menu so I could have longer, but not visible, page titles to satisfy SEO. Sounds like I might need to compromise one way or the other.
    – JLEM
    Commented Sep 24 at 13:00

Your Answer

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

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