【问题标题】:Wordpress Footer MenusWordpress 页脚菜单
【发布时间】:2020-04-07 08:59:28
【问题描述】:

我正在制作我的第一个 wordpress 儿童主题。在我的页脚中,我希望能够设置三个不同的菜单,但问题是,它不起作用,它一直在使用我的“页脚”

这是我的页脚 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>

这是我的函数 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'),
    ) );

那么,我如何让我的“footer2”显示('Footer Menu Colum 2')而不是('Footer Menu Colum 1')

【问题讨论】:

  • wp_nav_menu($args);?

标签: php wordpress themes


【解决方案1】:

首先查看文件wp_nav_menu中如何调用WordPress菜单。

不同的菜单需要不同的 $args。它们不应重复,将出现在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>

【讨论】:

    【解决方案2】:

    您没有将$args 传递给wp_nav_menu()。你需要做的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-06
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多