• Resolved Garet H.

    (@pagetopixel)


    Hello, Great plugin!

    I am trying to add a custom body class if the widget is active on a certain page. In my case it is a slider.

    add_filter('body_class', function (array $classes) {
        if ( is_active_sidebar( 'slider' ) ) {
    		$classes[] = 'slider-active';
    	}
      return $classes;
    });
    

    This filter adds the class without issue but it is showing on all pages even though my widget is only set to display on the Home/Front. Is there a way I can set it to only show on the pages it is active on by adding a variable to check if the widget option is set to visible?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Body class if visible’ is closed to new replies.