admin管理员组文章数量:1435553
I've got a dynamic menu being generated, but instead of generating a page-item it generates a menu-item. What I would like it to do is generate page-items and all the rest of it so that I can show or highlight the current page a user is visiting.
my code is :
// header.php
<?php // Loading WordPress Custom Menu
wp_nav_menu( array(
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'menu_class' => 'nav navbar-nav',
'menu_id' => 'main-menu',
'walker' => new Cwd_wp_bootstrapwp_Walker_Nav_Menu()
) ); ?>
And then in the functions.php I have
add_action( 'after_setup_theme', 'cwd_wp_bootstrapwp_theme_setup' );
if ( ! function_exists( 'cwd_wp_bootstrapwp_theme_setup' ) ):
function cwd_wp_bootstrapwp_theme_setup() {
// Adds the main menu
register_nav_menus( array(
'main-menu' => __( 'Main Menu', 'cwd_wp_bootstrapwp' ),
) );
}
endif;
I've got a dynamic menu being generated, but instead of generating a page-item it generates a menu-item. What I would like it to do is generate page-items and all the rest of it so that I can show or highlight the current page a user is visiting.
my code is :
// header.php
<?php // Loading WordPress Custom Menu
wp_nav_menu( array(
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'menu_class' => 'nav navbar-nav',
'menu_id' => 'main-menu',
'walker' => new Cwd_wp_bootstrapwp_Walker_Nav_Menu()
) ); ?>
And then in the functions.php I have
add_action( 'after_setup_theme', 'cwd_wp_bootstrapwp_theme_setup' );
if ( ! function_exists( 'cwd_wp_bootstrapwp_theme_setup' ) ):
function cwd_wp_bootstrapwp_theme_setup() {
// Adds the main menu
register_nav_menus( array(
'main-menu' => __( 'Main Menu', 'cwd_wp_bootstrapwp' ),
) );
}
endif;
Share
Improve this question
edited Feb 21, 2014 at 1:51
kaiser
50.9k27 gold badges151 silver badges245 bronze badges
asked Feb 21, 2014 at 1:29
Dominic FrancisDominic Francis
101
2
- Do you mean highlight the menu item in the menu? – Brad Dalton Commented Feb 21, 2014 at 2:08
- Yes, so if you're on the blog page highlight the menu item that says blog. – Dominic Francis Commented Feb 21, 2014 at 8:17
1 Answer
Reset to default 0This is an example of CSS code which works with one specific theme.
You may need to change the classes depending on your theme.
.nav-primary .current-menu-item > a {
color: blue;
background-color: white;
}
This will highlight the background color of the current menu item to white and you can also change the font color which in this case is blue.
本文标签: My WordPress menu based on Twitter bootstrap creates menuitem and not pageitem
版权声明:本文标题:My WordPress menu based on Twitter bootstrap creates menu-item and not page-item 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745651894a2668479.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论