• Resolved Marc

    (@marcwp7)


    Hey there,

    It would be nice to add a class to the body or header in frontend to identify when the plugin made the menu change.

    This way one can apply different css styles or events dynamically.

    Thank you!

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

    (@themifyme)

    Hi Marc,

    Our Conditional Menus plugin can not modify your theme’s header / body it can only switch your menus as per your Conditional Settings ( that is the role of this plugin ).

    Thread Starter Marc

    (@marcwp7)

    I was able to get some time, and then I made this modification, it’s something quite simple.

    Inside the init.php file, and inside the function “theme_mod_nav_menu_locations”, put this line after the line $locations[$location] = $new_menu[ ‘menu’ ];

    add_filter( 'body_class', function( $classes ) {
    	return array_merge( $classes, array( 'conditional-menu' ) );
    } );

    Then this will add the “conditional-menu” class to the body of the HTML, and so one can, for example, as in my case, apply CSS changes to the header when a conditional menu is visible.

    Please add this modification to the code, it can be really useful.

    Thanks!

    Plugin Author themifyme

    (@themifyme)

    Hi Marc,

    Thank you for sharing the solution to your issue.

    That is actually not the purpose of the Conditional Menu plugin, as the header and other element styling are related to your Theme, not our plugin, but in case anybody will ask for this feature we will forward him to this thread.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[NEW Feature Suggestion] Class to identify in frontend’ is closed to new replies.