wp_get_sidebar() WordPress Function
The wp_get_sidebar() function is used to retrieve the sidebar name for the current page template. The sidebar name is set in the WordPress admin panel under Appearance > Widgets.
wp_get_sidebar( string $id ) #
Retrieves the registered sidebar with the given ID.
Parameters
- $id
(string)(Required)The sidebar ID.
Return
(array|null) The discovered sidebar, or null if it is not registered.
Source
File: wp-includes/widgets.php
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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |