admin管理员组文章数量:1037775
On a website I develop, some pages are in several sub-menus, like so:
home | product category a | products category b
* product a * product c
* product b * product b --> same as in previous menu
Now how do I get WordPress to add current-menu-item
and current-menu-parent
classes to "products category b" and "page b" instead of "product b" in the "product category a".
Currently, it seems that WordPress matches the entries in menu on a first encountered basis. So the entry in that appears first in the menu always takes precedence.
Instead I'd need WordPress to consider what was actually clicked.
So far, the easiest option I have found (no code changes required) is to add a parameter to the url to match a specific menu.
"page b" in "products category b" has its url appended with ?cat=b
. This way, the url is unique to a menu and WP matches it right.
Nevertheless, it's not ideal for SEO and caching. I am therefore still looking for a better solution.
On a website I develop, some pages are in several sub-menus, like so:
home | product category a | products category b
* product a * product c
* product b * product b --> same as in previous menu
Now how do I get WordPress to add current-menu-item
and current-menu-parent
classes to "products category b" and "page b" instead of "product b" in the "product category a".
Currently, it seems that WordPress matches the entries in menu on a first encountered basis. So the entry in that appears first in the menu always takes precedence.
Instead I'd need WordPress to consider what was actually clicked.
So far, the easiest option I have found (no code changes required) is to add a parameter to the url to match a specific menu.
"page b" in "products category b" has its url appended with ?cat=b
. This way, the url is unique to a menu and WP matches it right.
Nevertheless, it's not ideal for SEO and caching. I am therefore still looking for a better solution.
本文标签: having a page in multi submenu and match currentmenuitem
版权声明:本文标题:having a page in multi sub-menu and match current-menu-item 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1748251192a2275405.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论