Loosing Nav Active State in Wordpress Dynamic Menu

↘锁芯ラ 提交于 2019-12-12 04:45:56

问题


In the following section:

http://www.zimmernutrition.com.php53-23.ord1-1.websitetestlink.com/learning-center/

In the sidebar, if you click "Health Articles" and click one of the categories, the active "orange" state of "Learning Center" is lost. Articles are a custom post type and the categories are a related custom taxonomy.

Not sure if the menu is coded incorrectly, the CPT, the custom taxonomy or some combination.

Thanks for any help.

Brett


回答1:


Just for the record mine works. I'm using Chrome, but other browsers could well give issues.

I think that your CSS on the current-menu-item's ect. just needs more pseudo types.

Yours:

#main-navigation .current-menu-item > a:link,
#main-navigation .current-menu-ancestor > a:link,
#main-navigation .current_page_item > a:link,
#main-navigation .current_page_parent > a:link,
#main-navigation .current_page_ancestor > a:link {
  background: #e69433 url(images/template/nav-link-bg-over.jpg) left top repeat-x;
}

#main-navigation .current-menu-item > a,
#main-navigation .current-menu-ancestor > a,
#main-navigation .current_page_item > a,
#main-navigation .current_page_parent > a,
#main-navigation .current_page_ancestor > a {
  color: #000;
}

I would combine them like so: (minus the extra classes)

#main-navigation .current-menu-item a,
#main-navigation .current-menu-item a:link,
#main-navigation .current-menu-item a:visited,
#main-navigation .current-page-parent a,
#main-navigation .current-page-parent a:link,
#main-navigation .current-page-parent a:visited {
  background: #e69433 url(images/template/nav-link-bg-over.jpg) left top repeat-x;
  color: #000;
}

#main-navigation .current-menu-item a:hover,
#main-navigation .current-menu-item a:active,
#main-navigation .current-page-parent a:hover,
#main-navigation .current-page-parent a:active {
  background: orange url(images/template/nav-link-bg-over.jpg) left top repeat-x;
  color: pink;
}

Also the > is something that non modern browsers won't understand. Might be safer to remove it completely.

- UPDATE -

Looking closer at the list items on both the parent and the child page, this is what you have:

Parent Item <li id="menu-item-142" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-15 current_page_item menu-item-142">

Child Page <li id="menu-item-142" class="menu-item menu-item-type-post_type menu-item-object-page current-page-ancestor current-menu-ancestor current-menu-parent current-page-parent current_page_parent current_page_ancestor menu-item-142">

I've adjusted the styles above to match the necessary classes.



来源:https://stackoverflow.com/questions/11942798/loosing-nav-active-state-in-wordpress-dynamic-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!