Title: Count widgets in sidebar
Last modified: August 19, 2016

---

# Count widgets in sidebar

 *  Resolved [q-styler](https://wordpress.org/support/users/q-styler/)
 * (@q-styler)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/count-widgets-in-sidebar/)
 * Hi!
    I’m looking for a way to count a number of a widgets that has sidebar to
   make my theme more dynamic. Didn’t find any references in codex and in google.
   Is there any way to do it?
 * Thank you!

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/count-widgets-in-sidebar/#post-1524560)
 * The Right Now module in the dashboard uses this:
 *     ```
       if ( !empty($wp_registered_sidebars) ) {
       		$sidebars_widgets = wp_get_sidebars_widgets();
       		$num_widgets = 0;
       		foreach ( (array) $sidebars_widgets as $k => $v ) {
       			if ( 'wp_inactive_widgets' == $k )
       				continue;
       			if ( is_array($v) )
       				$num_widgets = $num_widgets + count($v);
       		}
       		$num = number_format_i18n( $num_widgets );
       ```
   
 * See wp-admin/includes/dashboard.php
 *  Thread Starter [q-styler](https://wordpress.org/support/users/q-styler/)
 * (@q-styler)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/count-widgets-in-sidebar/#post-1524568)
 * Thank you!
    That helped somehow 🙂

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

The topic ‘Count widgets in sidebar’ is closed to new replies.

## Tags

 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * 2 replies
 * 2 participants
 * Last reply from: [q-styler](https://wordpress.org/support/users/q-styler/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/count-widgets-in-sidebar/#post-1524568)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
