我正在制作我的第一个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'),
) );
那么,我如何使我的"页脚2"显示("页脚菜单栏2"(而不是("页脚选单栏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>
您没有将$args
传递给wp_nav_menu()
。你需要做:
...
<?php
$args = array(
'theme_location' => 'footer2'
);
wp_nav_menu($args); ?>
...