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
- 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
1 Answer
Reset to default 1I 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.
本文标签:
版权声明:本文标题:Primary menu item is not highlighting when page is active even though it is linked from a url with query string to pre-populate 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736290253a1928474.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论