在 Wordpress 动态菜单中失去导航活动状态 [英] Loosing Nav Active State in Wordpress Dynamic Menu

查看:20
本文介绍了在 Wordpress 动态菜单中失去导航活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下部分:

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.

不确定菜单是否编码错误、CPT、自定义分类法或某些组合.

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

感谢您的帮助.

布雷特

推荐答案

仅供记录我的作品.我使用的是 Chrome,但其他浏览器很可能会出现问题.

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

我认为您在 current-menu-item 等方面的 CSS.只是需要更多的伪类型.

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

您的:

#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;
}

我会像这样组合它们: (减去额外的类)

#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.

- 更新-

仔细查看父页面和子页面上的列表项,这就是您所拥有的:

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

父项<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">

子页面<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-parentcurrent-page-parent current_page_parent current_page_ancestor menu-item-142">

我已经调整上面的样式以匹配必要的类.

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

这篇关于在 Wordpress 动态菜单中失去导航活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆