开发者

Adding active class to wordpress 3+ menu

I'm having problems with adding active class to wordpress menu. (If is home highlight home, if blog highlight blog and so on... )

I'm using superfish menu.

I have this in my functions.php

function me_register_menu() {
register_nav_menu('main-menu', __('Main Menu'));
}       

add_action( 'init', 'me_regis开发者_StackOverflowter_menu' ); 

And in my header, where my menu is

<?php 
if ( has_nav_menu ( 'main-menu' ) ) {
wp_nav_menu( array ( 'theme_location' => 'main-menu' , 'container_class' => 'grid_7', 'container_id' => 'menu' , 'menu_class' => 'menu sf-menu') );
}
?>

I'd like to add .active class to my active menu. Any ideas how?


You can do it with css. It's hard to say without seeing your page, but this should work:

/* Highlight using list element */
.menu-item a:active{
background:#999 !important;
color:#fff;
}

/* Highlight using link element */
.menu-item:active {
text-decoration:underline;
background:#666 !important;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜