WordPress wp nav menu Filter
[resolved] WordPress WP Nav Menu Filter with Top Level Menu ID (2 posts)

  1. InHouse
    Posted 2 years ago #

    Hi, I'm trying to use WordPress wp nav menu Filter with an ID of a top level menu item. What I'm finding is that the submenu ID needs to be a submenu. I'm trying to do this because when viewing a custom post type archive, I need to show a specific menu in the sidebar. If I use a 2nd or 3rd level menu ID this works great but doesn't seem to work with a top level ID. Is this a bug or is there a way to achieve this another way? Thanks in advance for any help!

    if ((is_tax("custom_post_cat") || get_post_type() == "custom_post" {
    	wp_nav_menu(array(  'container_class' => 'sidebar-menu', 'theme_location' => 'main-menu', 'depth' => '4', 'submenu' => '53' ));


  2. InHouse
    Posted 2 years ago #

    Wow, I think I just accidently found the answer to this. If I choose an ID numeral one lower than the ID of the first desired list item it works. For instance, I wanted these items in the list:

    <li class="menu-item-28"><a href="#">Item 1</a></li>
    <li class="menu-item-29"><a href="#">Item 2</a></li>

    So the ID I use is 27.

    wp_nav_menu(array(  'container_class' => 'sidebar-menu', 'theme_location' => 'main-menu', 'depth' => '4', 'submenu' => '27' ));

    I don't think this is really spelled out in the FAQs but for anyone else, I hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress wp nav menu Filter
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic