2012-01-15 56 views
0

我正在使用一个非常基本的主题WordPress的默认安装。我遇到的问题是,当我查看帖子,普通帖子或自定义帖子类型时,菜单不会突出显示。菜单高亮当前帖子

例如,我点击“博客”,博客文章存档页面显示,菜单仍然正确突出显示,但是当我打开一个随机文章时,菜单突出显示消失了。

有没有解决这个问题?

回答

1

巧合的是,我昨天为客户的主题设置了一些东西。你可能有一个突出显示菜单项的类?你可以发布你的主题代码的样子 - 可能这是像在主题中的header.php。

我所做的是比较页面的标题和菜单项,并设置该类。喜欢的东西:

class="<?php if(trim(wp_title("",false))=="Home") echo "active"; ?>" 

其设置类为“主动”,如果wp_title是“家”。这是一个静态导航菜单,包含每个页面的链接;你的环境可能会在打印导航页面标题的循环中动态显示,所以最好能看到你的代码能够提供帮助。

0

或者你可以有一个条件,

<?php if (is_single() ?> 
0
For highlighting a particular menu,you can try this in ur style.css file of your website:- 

#nav li.current_page_item a{ 
color:#fff !important; 
background-color:#82bd42; 
text-decoration:none; 
-moz-border-radius: 3px; 
-webkit-border-radius: 3px; 
border-radius: 3px; 
padding:10px 10px; 
} 

Where nav is the id of the <nav id="id"> tag where menu is being located in 
header.php,like this:- 

<nav id="nav"> 

    <?php wp_nav_menu(array('theme_location' => 'primary')); ?> 

</nav>