2012-01-15 37 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>