1

So I'm currently trying to figure out how to display both my main menu items and my submenu items separately in my footer.

I want to display them both in separate columns (bootstrap) and am having trouble displaying them.

Here's what I have

<div class="col-sm-3 col-md-3">
    <ul>
        <?php 
            wp_nav_menu( array(
            'theme_location' => 'primary',
            'depth' => 1,
            'container' => false,
          );
        ?>
    </ul>
</div>
<div class="col-sm-3 col-md-3">
    <ul>
        <!-- Add Submenu Items here -->
    </ul>
</div>

Not sure if this is the proper way to display the footer, I'm also using navwalker.

Any help would be appreciated, thanks!

1 Answer 1

2

This is actually not that difficult if you already know how the walker class works. You would need two calls to wp_nav_menu. The first one you have should already work, because the function natively allows you to select only the top level.

What it doesn't allow you to is to select everything but the top level. So you need a separate walker, which you would call like this:

wp_nav_menu( array(
    'theme_location' => 'primary',
    'walker' => new wpse215647_walker(),
    'container' => false,
) );

In your walker you must make sure all items are included, except the top level. That question already has an answer here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.