is_dynamic_sidebar()

Determines whether the dynamic sidebar is enabled and used by the theme.


Description Description

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.


Return Return

(bool) True, if using widgets. False, if not using widgets.


Top ↑

Source Source

File: wp-includes/widgets.php

function is_dynamic_sidebar() {
	global $wp_registered_widgets, $wp_registered_sidebars;
	$sidebars_widgets = get_option( 'sidebars_widgets' );
	foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
		if ( ! empty( $sidebars_widgets[ $index ] ) ) {
			foreach ( (array) $sidebars_widgets[ $index ] as $widget ) {
				if ( array_key_exists( $widget, $wp_registered_widgets ) ) {
					return true;
				}
			}
		}
	}
	return false;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.