Mads Welling Andersen
Mads Welling Andersen

Reputation: 11

Wordpress Footer Menus

I'm making my first wordpress child theme. In my footer, i would like to be able to setup three different menus, but the problem is, it doenst work, it keeps using my "footer

This is my footer php

    <footer id="colophon" class="site-footer">
    <div class="site-info">

        <nav class="footer-colum1">
            <?php
            $args = array(
                'theme_location' => 'footer'    );
            wp_nav_menu();
            ?>
        </nav>

        <nav class="footer-colum2">
            <?php
            $args = array(
                'theme_location' => 'footer2'   );
            wp_nav_menu();

            ?>
        </nav>

        <nav class="footer-colum3">
            <?php
            wp_nav_menu();
            $args = array(
                'theme_location' => 'footer3'   );


            ?>
        </nav>

        <nav class="footer-colum4">
            <?php
            wp_nav_menu();
            $args = array(
                'theme_location' => 'footer4'   );


            ?>
        </nav>

This is my functions php

        register_nav_menus( array(
        'menu-1' => esc_html__( 'Primary Menu', 'aagaardefterskole'  ),
        'footer' => __('Footer Menu Colum 1'),
        'footer2' => __('Footer Menu Colum 2'),
        'footer3' => __('Footer Menu Colum 3'),
    ) );

So, how do i make my "footer2" show the ('Footer Menu Colum 2') and not the ('Footer Menu Colum 1')

Upvotes: 0

Views: 1086

Answers (2)

Krupal Panchal
Krupal Panchal

Reputation: 1545

First check how to call WordPress menu in the file wp_nav_menu.

You need different $args for different menus. They should not be repeat and will come before wp_nav-menu().

    <nav class="footer-colum1">
        <?php
        $args = array(
            'theme_location' => 'footer'    );
        wp_nav_menu($args);
        ?>
    </nav>

    <nav class="footer-colum2">
        <?php
        $args2 = array(
            'theme_location' => 'footer2'   );
        wp_nav_menu($args2);

        ?>
    </nav>

    <nav class="footer-colum3">
        <?php

        $args3 = array(
            'theme_location' => 'footer3'   );
        wp_nav_menu($args3);

        ?>
    </nav>

    <nav class="footer-colum4">
        <?php

        $args4 = array(
            'theme_location' => 'footer4'   );
        wp_nav_menu($args4);

        ?>
    </nav>

Upvotes: 1

Julien Verneaut
Julien Verneaut

Reputation: 348

You are not passing $args to wp_nav_menu(). You need to do:

...

<?php

$args = array(
   'theme_location' => 'footer2'
);
wp_nav_menu($args); ?>

...

Upvotes: 0

Related Questions