Title: rest_prepare_sidebar
Published: July 20, 2021
Last modified: February 24, 2026

---

# apply_filters( ‘rest_prepare_sidebar’, WP_REST_Response $response, array $raw_sidebar, WP_REST_Request $request )

## In this article

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

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

Filters the REST API response for a sidebar.

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

 `$response`[WP_REST_Response](https://developer.wordpress.org/reference/classes/wp_rest_response/)

The response object.

`$raw_sidebar`array

The raw sidebar data.

`$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)

The request object.

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

    ```php
    return apply_filters( 'rest_prepare_sidebar', $response, $raw_sidebar, $request );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php#L402)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php#L402-L402)

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

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

Prepares a single sidebar output for response.

  |

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

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

## User Contributed Notes

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