0

I´m using a wordpress default installation with a very basic theme. The problem I have is that when I´m viewing a post, a normal post or a custom post type, the menu does not get highlighted.

For example, I click "Blog" and the blog posts archive page shows and the menu is still highlighted properly, but when I open a random post the menu highlight is gone.

is there any fix for this?

Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
Ricardo Ribeiro
  • 87
  • 1
  • 2
  • 10

3 Answers3

1

Coincidentally, I set something up for this yesterday for a client's theme. You probably have a class for highlighting the menu item? Can you post what your theme code looks like--probably this is in something like header.php within the theme.

What I did was compare the title of the page with the menu item, and set that class. Something like:

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

which sets the class to "active" if the wp_title is "Home". This is a static navigation menu with links for each page; yours might be dynamic within a loop printing the page titles for navigation, so it would be good to see your code to be able to help.

Eve Freeman
  • 32,467
  • 4
  • 86
  • 101
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>
0

or you can have a condition,

<?php if (is_single() ?>
Sufiyan Ghori
  • 18,164
  • 14
  • 82
  • 110