• Resolved q-styler

    (@q-styler)


    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)
  • 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

    (@q-styler)

    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.