• 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

Filter stops working after enabling HTML5

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 › Filter stops working after enabling HTML5

This topic is: resolved

Tagged: html5, nav_menu_css_class

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 8 months ago by Gary Jones.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • September 17, 2013 at 10:18 am #62997
    Walter
    Member

    Hello,

    I'm using the following code to add the "current" class to all current items, parents and ancestors.

    add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
    function special_nav_class($classes, $item){
    if(( in_array('current-menu-item', $classes) ) ||
    ( in_array('current-menu-parent', $classes) ) ||
    ( in_array('current-menu-ancestor', $classes) ) ||
    ( in_array('current-page-item', $classes) ) ||
    ( in_array('current-page-parent', $classes) ) ||
    ( in_array('current-page-ancestor', $classes) ) ||
    ( in_array('current-post-item', $classes) ) ||
    ( in_array('current-post-parent', $classes) ) ||
    ( in_array('current-post-ancestor', $classes)
    ))
    {
    $classes[] = 'current ';
    }
    return $classes;
    }

    However, with add_theme_support( 'html5' ); this code stops working.

    Anybody has a solution for this?

    September 17, 2013 at 10:27 am #63001
    Walter
    Member

    Sorry, it's my fault.

    September 17, 2013 at 7:32 pm #63092
    Gary Jones
    Member

    Why would you do this? current is a very generic class - it gives no indication of what it should be for, and if it's used for something else, then you're going to have problems. The current-* nav classes are necessarily descriptive.

    .menu-item[class*="current"] {
        ...
    }
    

    might work.


    WordPress Engineer, and key contributor the Genesis Framework | @GaryJ

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 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