Title: dynamic_sidebar() function without call
Last modified: August 19, 2016

---

# dynamic_sidebar() function without call

 *  [Bimalkumar Rekhadiya](https://wordpress.org/support/users/bimaljr/)
 * (@bimaljr)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/dynamic_sidebar-function-without-call/)
 * Hello,
 * I am using Widget Logic plugin to show/hide widgets according to my site pages.
 * I want to create logic like If there is no widget than there is no widget wrapper
   in content.
 * Example:
 *     ```
       $the_sidebars = wp_get_sidebars_widgets();
       $featured     = count( $the_sidebars['featured-widget-area'] );
       $featured2    = count( $the_sidebars['featured2-widget-area'] );
   
       if( $featured>0 && $featured2>0 ){
       echo '<div id="featured-widget-wrapper">';
       dynamic_sidebar( 'featured-widget-area' );
       dynamic_sidebar( 'featured2-widget-area' );
       echo '</div>';
       }
       ```
   
 * The problem is that the $featured variable is always with all widgets that are
   currently set, but I need only widgets that are available for current post/page.(
   I am disabling widgets with Widget Logic plugin.)
 * I think I need to check output of a sidebar but I don’t know the function. the
   dynamic_sidebar() always calls and print widgets. So is there any function which
   works same as dynamic_sidebar() except call and print the widgets?
 * Thanks
    Bimal

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/dynamic_sidebar-function-without-call/#post-1952613)
 * check the code of sidebar-footer.php of Twenty Ten;
    or `is_active_sidebar()`
   [http://codex.wordpress.org/Function_Reference/is_active_sidebar](http://codex.wordpress.org/Function_Reference/is_active_sidebar)
 *  [ferahl](https://wordpress.org/support/users/ferahl/)
 * (@ferahl)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/dynamic_sidebar-function-without-call/#post-1953017)
 *     ```
       // Get the sidebars contents
       $widget_sidebars_content = array();
       foreach($widget_sidebars_names as $sidebar_name)
       {
       	ob_start();
       	dynamic_sidebar($sidebar_name);
       	array_push($widget_sidebars_content, ob_get_clean());
       }
       ```
   

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

The topic ‘dynamic_sidebar() function without call’ is closed to new replies.

 * 2 replies
 * 3 participants
 * Last reply from: [ferahl](https://wordpress.org/support/users/ferahl/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/dynamic_sidebar-function-without-call/#post-1953017)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
