• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Active State for Blog Menu Item for Individual Blog Posts

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Active State for Blog Menu Item for Individual Blog Posts

This topic is: not resolved

Tagged: navigation

  • This topic has 3 replies, 2 voices, and was last updated 11 years, 5 months ago by efuller.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • June 19, 2014 at 3:45 pm #110658
    brettatkin
    Member

    On the following site, when you visit this page (the main blog page), the 'Blog' menu item has an 'active' background color.

    http://brettatkin.com/blog/

    When you visit an individual post, you lose the 'active' state for the 'Blog' menu item.

    http://brettatkin.com/blog/the-web-apps-i-use/

    Now, I added the follow CSS to fix this issue for parent/child pages.

    .current-page-ancestor > a {
    background-color: #3B6E8F;
    }

    Looking at the code, WP isn't adding a .current-page-ancestor class to the main blog menu item when on individual blog page. It's not adding any special classes at all. I have the following for a custom permalink structure:

    /blog/%postname%/

    On non-Genesis sites I've created, I haven't had this problem. .current_page_parent is getting added to the main blog menu item. For example:

    http://www.juliewinklegiulioni.com/blog/leadership-matters/plaques-and-platitudes-can-lead-to-paralysis/

    Is this an issue with Genesis, or something I missed?

    Thanks

    June 20, 2014 at 7:26 am #110777
    efuller
    Member

    Try adding this code to your functions.php

    
    function add_custom_class($classes=array(), $menu_item=false) {
        if ( !is_page() && 'Blog' == $menu_item->title && 
                !in_array( 'current-menu-item', $classes ) ) {
            $classes[] = 'current-menu-item';        
        }                    
        return $classes;
    }
    add_filter('nav_menu_css_class', 'add_custom_class', 100, 2); 
    

    I am a web developer

    June 23, 2014 at 11:35 am #111183
    brettatkin
    Member

    Thanks, this worked with one modification. I had to add the following to the if statement because the Blog link was active on the home page.

    !is_home()

    Shouldn't this be happening automatically though?

    June 23, 2014 at 12:01 pm #111188
    efuller
    Member

    I do not believe this is the default behavior of the Genesis navigation. It will highlight active pages, but not pages that belong to a specific category.


    I am a web developer

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble