wp_get_sidebar()WP 5.9.0

Retrieves the registered sidebar with the given ID.

No Hooks.

Return

Array|null. The discovered sidebar, or null if it is not registered.

Usage

wp_get_sidebar( $id );
$id(string) (required)
The sidebar ID.

Notes

  • Global. Array. $wp_registered_sidebars The registered sidebars.

Changelog

Since 5.9.0 Introduced.

Code of wp_get_sidebar() WP 6.0

function wp_get_sidebar( $id ) {
	global $wp_registered_sidebars;

	foreach ( (array) $wp_registered_sidebars as $sidebar ) {
		if ( $sidebar['id'] === $id ) {
			return $sidebar;
		}
	}

	if ( 'wp_inactive_widgets' === $id ) {
		return array(
			'id'   => 'wp_inactive_widgets',
			'name' => __( 'Inactive widgets' ),
		);
	}

	return null;
}