• Resolved Paul Wright

    (@signyourbikeout)


    Hello,

    I’ve used plugins and some php to add the current-menu-item class to the wordpress menu on single pages before, but it seems that with the update to WordPress 3.0 and the new menu system, the plugins and hacks I was using no longer work.

    Does anyone have a way to add a class to the menu during single.php views for the new menu?

    Thanks,
    Paul

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Paul Wright

    (@signyourbikeout)

    What I was needing was a way to highlight the page in the nav that was pulling specific categories. So my request wasn’t really clear. The best way to accomplish what I was looking for is to add a class to the body tag that names the category. Then you can use css to highlight the specific nav item.

    <?php $class=”;
    if(is_single()) {
    $category = get_the_category();
    $class .= $category[0]->slug;
    }?>
    <body <?php if (function_exists(‘body_class’)) body_class($class ); ?>>

    Then for instance with CSS,

    .articles #menu-item-10 {
    background-color:#000;
    }

    Hope that helps someone else

    Try specifying CSS for the following classes: .current-menu-item and current-post-parent.

    Thanks guys! You got me on the right track after hours of searching. I wanted to mark a specific top menu item as active when a single post is viewed. Namely the “Archive” item. All I needed was this little CSS snippet (I use a Child Theme of TwentyTen):

    .single-post #menu-item-2299 a {
    color:#fff;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Highlight Current Category Single Page With New WP3.0 wp_nav_menu’ is closed to new replies.