最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

having a page in multi sub-menu and match current-menu-item

programmeradmin4浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论