最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

menus - How to include the parent page link in this wp_nav_menu walker

programmeradmin0浏览0评论

I've got a site with a sidebar of 'sub-navigation' I also need to have those links 'parent page' in the navigation also. So, for example I've got

Parent

child 1

child 2

child 3

but the php only gives me

child 1

child 2

child 3

the code is here -

<nav id="sub-navigation">
    <?php wp_nav_menu( array('theme_location' => 'main-navigation', 'container' => '', 'walker' => new Related_Sub_Items_Walker(), 'start_depth' => 1, 'include_parent' => 1, 'strict_sub' => 1, 'only_related' => 1, 'filter' => 0, 'filter_selection' => 0, ) ); ?>
</nav>

Any help would be greatly appreciated. I need it 'within' the navigation due to how I've currently styled the look of it.

I've got a site with a sidebar of 'sub-navigation' I also need to have those links 'parent page' in the navigation also. So, for example I've got

Parent

child 1

child 2

child 3

but the php only gives me

child 1

child 2

child 3

the code is here -

<nav id="sub-navigation">
    <?php wp_nav_menu( array('theme_location' => 'main-navigation', 'container' => '', 'walker' => new Related_Sub_Items_Walker(), 'start_depth' => 1, 'include_parent' => 1, 'strict_sub' => 1, 'only_related' => 1, 'filter' => 0, 'filter_selection' => 0, ) ); ?>
</nav>

Any help would be greatly appreciated. I need it 'within' the navigation due to how I've currently styled the look of it.

Share Improve this question asked Nov 7, 2013 at 23:16 Stuart RobsonStuart Robson 1231 gold badge1 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

WordPress does not have the class Related_Sub_Items_Walker. It looks like you're using the plugin Advanced Menu Widget.

Judging by the widget's source, you want to use 0 for the start_depth to include the parent. This is untested.

<nav id="sub-navigation">
  <?php
    wp_nav_menu( array(
      'theme_location' => 'main-navigation',
       'container' => '',
       'walker' => new Related_Sub_Items_Walker(),
       'start_depth' => 0, // 0-indexed
       'include_parent' => 1,
       'strict_sub' => 1,
       'only_related' => 1,
       'filter' => 0,
       'filter_selection' => 0,
    ) );
  ?>
</nav>
发布评论

评论列表(0)

  1. 暂无评论