• Hello everyone
    I’m using this beautiful plugin to display some custom menu widgets on a bunch of pages. That widget area is empty on a lot pages and I’d need to know where it’s empty for styling reasons.
    I thought to add a class in my template to mark the pages in which the widget area is empty, I tried to set it like

    <?php
    if(!dynamic_sidebar('my-conditional-widgets'))
      $class = "has-no-widgets"; ?>
    <div id="myDiv" class="myClass <?php echo $class; ?>">

    however, it seems dynamic_sidebar() always returns true. I guess it might be because it’s not *really* empty, but turns out empty due to the plugin conditions.
    Is there a better way to know if there are no widget to display?

    Thank you in advance for any help.

    https://wordpress.org/plugins/conditional-widgets/

  • The topic ‘How to know if there are no widgets to display’ is closed to new replies.