Title: Problem with is_active_sidebar Query
Last modified: August 31, 2016

---

# Problem with is_active_sidebar Query

 *  Resolved [cs-web](https://wordpress.org/support/users/cs-web/)
 * (@cs-web)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/)
 * Hello,
    I have installed your great plugin. But now I have a problem with my 
   if-query in my theme (code see below) If I have assigned a widget to the area
   and activate it on one page, on the other pages the else-clause not working.
 * Can you help?
 * Thanks.
 *     ```
       <?php if ( is_active_sidebar( 'slider-widget-area' ) ) : ?>
                           <?php dynamic_sidebar( 'slider-widget-area' ); ?>
   
                               <?php else : ?>
                                       <img src="<?php header_image(); ?>" width="100%" height="auto" alt="" />
   
                                       <?php endif; ?>
       ```
   
 * [https://wordpress.org/plugins/widget-options/](https://wordpress.org/plugins/widget-options/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Jeffrey Carandang](https://wordpress.org/support/users/phpbits/)
 * (@phpbits)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062616)
 * Hi,
 * Congratulations for choosing this plugin and thanks a lot for using it. Regarding
   your concern is_active_sidebar() is checking if there is a widget inside the 
   sidebar which in that case there is so the else function will not be called. 
   You can use the script below instead of that one, just make sure to change “slider-
   widget-area” to the right one. Let me know how it goes. Thanks!
 *     ```
       <?php if ( is_active_sidebar( 'slider-widget-area' ) ){
       	dynamic_sidebar( 'slider-widget-area' );
       } ?>
       <img src="<?php header_image(); ?>" class="sidebar-placeholder" style="display:none;" width="100%" height="auto" alt="" />
       <script type="text/javascript">
       	$(document).ready(function(){
       		if( $('.slider-widget-area').height() < 10 ){
       			$('.sidebar-placeholder').show();
       		}
       	});
       </script>
       ```
   
 * Cheers,
    phpbits
 *  Thread Starter [cs-web](https://wordpress.org/support/users/cs-web/)
 * (@cs-web)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062700)
 * Hi,
    I have used your code, but it doesn’t works. It is the same problem. The
   Slider will display, but the exceptions not.
 * But with the old plugin “Display widgets” my code works.
 * Cheers,
 *  [Jeffrey Carandang](https://wordpress.org/support/users/phpbits/)
 * (@phpbits)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062709)
 * Hi,
 * Can you post your website link? Thanks!
 * Cheers,
    phpbits
 *  Thread Starter [cs-web](https://wordpress.org/support/users/cs-web/)
 * (@cs-web)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062712)
 * Hi,
    can I send you the Link via Mail? It’s not a public project 😉
 *  Thread Starter [cs-web](https://wordpress.org/support/users/cs-web/)
 * (@cs-web)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062830)
 * Hi phpbits,
    With the Safari Developer Plugin I get this Error:
 * TypeError: $ is not a function. (In ‘$(document)’, ‘$’ is undefined)
    (anonyme
   Funktion)ueber-uns:57
 *     ```
       <script type="text/javascript">
                       $(document).ready(function() {
                           if ($('.slider').height() < 10) {
                               $('.sidebar-placeholder').show();
                           }
                       });
   
                   </script>
       ```
   
 *  [Jeffrey Carandang](https://wordpress.org/support/users/phpbits/)
 * (@phpbits)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062941)
 * Hi,
 * Not sure why I didn’t get email notification when you replied. I hope it’s not
   too late to solve the issue. You can use this one to fix the $ issue :
 *     ```
       <script type="text/javascript">
                       jQuery(document).ready(function() {
                           if ( jQuery('.slider').height() < 10) {
                               jQuery('.sidebar-placeholder').show();
                           }
                       });
   
                   </script>
       ```
   
 * Let me know how it goes. Thanks!
 * Cheers,
    phpbits
 *  Thread Starter [cs-web](https://wordpress.org/support/users/cs-web/)
 * (@cs-web)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062942)
 * Hi,
    no problem. I don’t get a error message, but I get the widget content and
   in additional the alternative header picture. I want use the meta-slider for 
   special pages. For other I want set up an costumer header.
 * With the old plugin the php if-clause works fine. (display-widgets) 🙁

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Problem with is_active_sidebar Query’ is closed to new replies.

 * ![](https://ps.w.org/widget-options/assets/icon-256x256.gif?rev=2513739)
 * [Widget Options – Advanced Conditional Visibility for Gutenberg Blocks & Classic Widgets](https://wordpress.org/plugins/widget-options/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widget-options/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widget-options/)
 * [Active Topics](https://wordpress.org/support/plugin/widget-options/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widget-options/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widget-options/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [cs-web](https://wordpress.org/support/users/cs-web/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/problem-with-is_active_sidebar-query/#post-7062942)
 * Status: resolved