仅限WordPress wp_nav_menu特定子菜单 [英] WordPress wp_nav_menu specific sub menu only
问题描述
我想创建一个菜单,仅拉出特定页面的子菜单选项.
I want to create a menu that pulls only the sub-menu options for a particular page.
例如,如果菜单选项DASHBOARD具有MESSAGE BOARD和CALENDAR子菜单,我希望能够仅用MESSAGE BOARD和CALENDAR创建一个单独的菜单.
For example, if the menu option DASHBOARD has the sub-menus MESSAGE BOARD and CALENDAR, I want to be able to create a separate menu with just MESSAGE BOARD and CALENDAR.
我想在没有wp_list_pages函数的情况下执行此操作,以便可以使用WordPress中的外观">菜单"选项卡来管理菜单选项.
I'd like to do this without the wp_list_pages function so that the menu options can be managed using the Appearances > Menus tab in WordPress.
谢谢!
推荐答案
如果我对您的理解正确,那么您是否希望为子页面添加其他菜单项?
If I understood you correctly, you want additional menu items for sub pages?
I.E.您有一个看起来像这样的菜单
I.E. You have a menu that looks like this
关于仪表板的常见问题联系我们
HOME ABOUT DASHBOARD FAQ CONTACT
信息中心有2个子页面->信息日历
DASHBOARD has 2 sub-pages -> BOARD CALENDAR
当您在DASHBOARD页面上时,您希望BOARD和CALENDAR页面显示如下:
When you are on the DASHBOARD page you want the BOARD and CALENDAR pagees to show like this:
关于仪表板常见问题解答的首页 董事会日历
HOME ABOUT DASHBOAR FAQ CONTACT BOARD CALENDAR
您可以像这样在functions.php中添加一个附加菜单
You can add an aditional menu in functions.php like this
<?php if (function_exists('register_nav_menus'))
{
register_nav_menus
(
array
(
'main_nav'=>'main menu', // your main menu
'dash_nav'=>'dashboard menu', //your dashboard menu
)
);
}?>
然后为仪表板创建页面模板,该模板将具有以下内容:
And then create a page template for dashboard which will have this:
<?php wp_nav_menu(array('menu'=>'dashboard menu'));?>
好吧,您可以编辑header.php并添加类似的内容
Well you could edit the header.php and add something like this
<?php if (is_page_template('dashboard.php') :?>
<link href="csspath" rel="stylesheet" type="text/css" />
<?php endif;?>
这样,您将添加另一个覆盖子菜单的css文件.
That way you add another css file that overrides the submenu.
这篇关于仅限WordPress wp_nav_menu特定子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!