Support » Plugin: Page scroll to id » Want to highlight "Blog" menu when viewing individual blog post

  • Resolved Jane


    My site is:

    I’m able to get the menu item associated with the current section to highlight nicely when I click on any of the top menu items. (thanks for your help with this!)

    However, when I click on one of the Blog posts, such as “Breathing Space”, I want the “Blog” menu item to be highlighted in green (#85C441) and it’s not. I added a “<div id=”blogPage”> … </div> wrapper around the “Breathing Space” blog post as a test, but it didn’t fix this issue. If you have any suggestions for how I can get the “Blog” menu item to highlight when I’m on an individual Blog post I’d appreciate it.

    Thanks in advance for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author malihu


    Your blog posts pages body tag gets the class single-post by WordPress. You could use this class in your CSS to target the ‘Blog’ menu item:

    .single-post #top-menu > a{
        color: #85C441;

    This way the green color is applied only on .menu-item-79 (your ‘Blog’ link) and only when under the .single-post (the single-post page body class).

    Hi Malihu – Thanks for this solution! It worked perfectly.

    Here’s what worked for me. Place the following PHP code in your footer.php file right before the closing body tag </body>.

    <?php if (is_single() || is_category() || is_tag() || is_search()) {   //  displaying a single blog post or a blog archive ?>
        <script type="text/javascript">
    <?php } ?>

    For further explanation, I wrote a short piece here about it here: Keep “Blog” link highlighted when viewing a single post

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Want to highlight "Blog" menu when viewing individual blog post’ is closed to new replies.