简体   繁体   English

WordPress仅在侧边栏上显示第一个父级及其子菜单

[英]Wordpress display first parent and its sub-menu only on sidebar

I have a main navigation and all parents have children. 我有一个主要的导航,所有父母都有孩子。
Example: 例:
Parent Page A: 父页面A:

  • Child A1 儿童A1
    - Child A11 -儿童A11
    - Child A12 -儿童A12
    - Child A12 -儿童A12
    - Child A13 -儿童A13
  • Child A2 儿童A2
  • Child A3 儿童A3

Parent Page B: 父页面B:

  • Child B1 B1儿童
    - Child B11 -儿童B11
    - Child B12 -儿童B12
    - Child B12 -儿童B12
    - Child B13 -儿童B13
  • Child B2 B2儿童

If we are click on Child A12, sidebar should looks like: 如果单击Child A12,则侧边栏应如下所示:
Parent Page A: 父页面A:

  • Child A1 儿童A1
    - Child A11 -儿童A11
    - Child A12 -儿童A12
    - Child A12 -儿童A12
    - Child A13 -儿童A13
  • Child A2 儿童A2
  • Child A3 儿童A3

Thanks. 谢谢。

I think you want to use vertical navigation menu like accordion, so look this to jquery simple vertical menu and on this base write your php code, also you can look on this example of php menu . 我想您想使用像手风琴这样的垂直导航菜单,因此请在jQuery简单的垂直菜单中查看此内容,并在此基础上编写您的php代码,也可以在此php菜单示例中查看 When you will split this two examples I gues you will recieve that functionality that you want. 当您拆分这两个示例时,我想您会收到所需的功能。

You should check out this plugin: http://wordpress.org/plugins/child-navigation/ 您应该查看此插件: http : //wordpress.org/plugins/child-navigation/

It adds some arguments to wp_nav_menu() 它将一些参数添加到wp_nav_menu()

This should do exactly what you want: 这应该完全满足您的要求:

wp_nav_menu( array( 
    'theme_location' => 'my_menu_location',
    'children_only' => TRUE,
    'children_start_level' => 1,
    'children_show_start_level' => true,
) ); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM