WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. inhouse
    Member
    Posted 6 months 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' ));

    http://wordpress.org/plugins/wordpress-wp-nav-menu-filter/

  2. inhouse
    Member
    Posted 6 months 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:

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

    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.

Reply

You must log in to post.

About this Plugin

About this Topic