Title: wp_get_sidebar
Published: February 3, 2022
Last modified: April 28, 2025

---

# wp_get_sidebar( string $id ): array|null

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#wp--skip-link--target)

Retrieves the registered sidebar with the given ID.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#parameters)󠁿

 `$id`stringrequired

The sidebar ID.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#return)󠁿

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

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#source)󠁿

    ```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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/widgets.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/widgets.php#L1064)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/widgets.php#L1064-L1081)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#related)󠁿

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

| Used by | Description | 
| [WP_REST_Widgets_Controller::check_read_sidebar_permission()](https://developer.wordpress.org/reference/classes/wp_rest_widgets_controller/check_read_sidebar_permission/)`wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php` |

Checks if a sidebar can be read publicly.

  | 
| [WP_REST_Sidebars_Controller::get_sidebar()](https://developer.wordpress.org/reference/classes/wp_rest_sidebars_controller/get_sidebar/)`wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php` |

Retrieves the registered sidebar with the given id.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_sidebar/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_sidebar%2F)
before being able to contribute a note or feedback.