WordPress wp_nav_menu帮助 [英] Wordpress wp_nav_menu help

查看:74
本文介绍了WordPress wp_nav_menu帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用wp_nav_menu生成导航菜单.尽管一切正常且菜单突出显示正常,但是如何使子页面也突出显示?

I am currently using wp_nav_menu to generate my nav menu. Although everything is working and menu highlighting is working, how do you get child pages to be highlighted as well?

例如,我有一个名为页面"的菜单项,该菜单项下有3个子页面.因此,当我在任何子页面中时,我都希望主页面仍然突出显示...使用wp_nav_menu ..怎么可能?

For example, I have a menu item named "Page" and it has 3 child pages under that. So when I am in any of the child pages, I want the main Page to still be highlighted...how is that possible with using wp_nav_menu..?

推荐答案

WordPress提供的body_class函数可以在这里为您提供帮助.

The body_class function which WordPress has can help you out here.

http://codex.wordpress.org/Function_Reference/body_class

您想要的是current-menu-parent,您可以在CSS中使用它.据我所知,记录的文档不多,但是这篇文章对您有帮助:

What you'll want is current-menu-parent which you can utilise in your CSS. Not particularly well documented as far as I can tell, but this article helps:

http://www.designisphilosophy.com/tutorials/highlight -current-page-or-category/

这篇关于WordPress wp_nav_menu帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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