admin管理员组

文章数量:1122846

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.

/
/?query_text=Hello

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

Share Improve this question asked Sep 20, 2024 at 19:52 JLEMJLEM 1 2
  • 1 instead of using the "custom links" element in the menu, use a "page" element. – mmm Commented Sep 20, 2024 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, 2024 at 12:58
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: