admin管理员组文章数量:1130349
I am currently working on my own theme. In this theme I want two menus topmenu and bottommenu.
In the functions.php file I have the following code:
// This adds the support to add a thumbnail and custom menus
function thumbnail_menu_support() {
add_theme_support( 'post-thumbnails' );
register_nav_menus(
array(
'topmenu' => __( 'Top menu' ),
'bottommenu' => __( 'Bottom menu' )
)
);
}
add_action( 'init', 'thumbnail_menu_support' );
In my header.php and in the footer.php I have the following code:
<?php wp_nav_menu( array(
'menu' => 'Top menu',
'menu_id' => 'topmenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'topmenu'
) ); ?>
and
wp_nav_menu( array(
'menu' => 'Bottom menu',
'menu_id' => 'bottommenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'bottommenu'
) );
Now, when I make a menu in the backend of Wordpress, and specify that it should only be in the top menu, it will be rendered in both menus.
See this:
I am currently working on my own theme. In this theme I want two menus topmenu and bottommenu.
In the functions.php file I have the following code:
// This adds the support to add a thumbnail and custom menus
function thumbnail_menu_support() {
add_theme_support( 'post-thumbnails' );
register_nav_menus(
array(
'topmenu' => __( 'Top menu' ),
'bottommenu' => __( 'Bottom menu' )
)
);
}
add_action( 'init', 'thumbnail_menu_support' );
In my header.php and in the footer.php I have the following code:
<?php wp_nav_menu( array(
'menu' => 'Top menu',
'menu_id' => 'topmenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'topmenu'
) ); ?>
and
wp_nav_menu( array(
'menu' => 'Bottom menu',
'menu_id' => 'bottommenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'bottommenu'
) );
Now, when I make a menu in the backend of Wordpress, and specify that it should only be in the top menu, it will be rendered in both menus.
See this:
Share Improve this question asked Dec 23, 2018 at 18:10 Christof KälinChristof Kälin 11 bronze badge1 Answer
Reset to default 0I actually found the answer on stackexchange as well: https://wordpress.stackexchange/a/184149/132736
I need to replace the 'theme-location' by 'theme_location'. I simply misread the function reference on the WordPress codex.
I am currently working on my own theme. In this theme I want two menus topmenu and bottommenu.
In the functions.php file I have the following code:
// This adds the support to add a thumbnail and custom menus
function thumbnail_menu_support() {
add_theme_support( 'post-thumbnails' );
register_nav_menus(
array(
'topmenu' => __( 'Top menu' ),
'bottommenu' => __( 'Bottom menu' )
)
);
}
add_action( 'init', 'thumbnail_menu_support' );
In my header.php and in the footer.php I have the following code:
<?php wp_nav_menu( array(
'menu' => 'Top menu',
'menu_id' => 'topmenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'topmenu'
) ); ?>
and
wp_nav_menu( array(
'menu' => 'Bottom menu',
'menu_id' => 'bottommenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'bottommenu'
) );
Now, when I make a menu in the backend of Wordpress, and specify that it should only be in the top menu, it will be rendered in both menus.
See this:
I am currently working on my own theme. In this theme I want two menus topmenu and bottommenu.
In the functions.php file I have the following code:
// This adds the support to add a thumbnail and custom menus
function thumbnail_menu_support() {
add_theme_support( 'post-thumbnails' );
register_nav_menus(
array(
'topmenu' => __( 'Top menu' ),
'bottommenu' => __( 'Bottom menu' )
)
);
}
add_action( 'init', 'thumbnail_menu_support' );
In my header.php and in the footer.php I have the following code:
<?php wp_nav_menu( array(
'menu' => 'Top menu',
'menu_id' => 'topmenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'topmenu'
) ); ?>
and
wp_nav_menu( array(
'menu' => 'Bottom menu',
'menu_id' => 'bottommenu',
'container' => false,
'fallback_cb' => false,
'theme-location' => 'bottommenu'
) );
Now, when I make a menu in the backend of Wordpress, and specify that it should only be in the top menu, it will be rendered in both menus.
See this:
Share Improve this question asked Dec 23, 2018 at 18:10 Christof KälinChristof Kälin 11 bronze badge1 Answer
Reset to default 0I actually found the answer on stackexchange as well: https://wordpress.stackexchange/a/184149/132736
I need to replace the 'theme-location' by 'theme_location'. I simply misread the function reference on the WordPress codex.
本文标签: Custom menu is rendered in all menus
版权声明:本文标题:Custom menu is rendered in all menus 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749068699a2311231.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论