rest_prepare_post_type
Filter HookDescription
Filters a post type returned from the REST API. Allows modification of the post type data right before it is returned.Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
View on GitHub
|
Hook Type | Filter |
Line Number | 290 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_REST_Response
|
$response
|
The response object. |
WP_Post_Type
|
$post_type
|
The original post type object. |
WP_REST_Request
|
$request
|
Request used to generate the response. |
Usage Examples
Basic Usage
<?php
// Hook into rest_prepare_post_type
add_filter('rest_prepare_post_type', 'my_custom_filter', 10, 3);
function my_custom_filter($response, $post_type, $request) {
// Your custom filtering logic here
return $response;
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php:290
- How this hook is used in WordPress core
<?php
285 *
286 * @param WP_REST_Response $response The response object.
287 * @param WP_Post_Type $post_type The original post type object.
288 * @param WP_REST_Request $request Request used to generate the response.
289 */
290 return apply_filters( 'rest_prepare_post_type', $response, $post_type, $request );
291 }
292
293 /**
294 * Prepares links for the request.
295 *
PHP Documentation
<?php
/**
* Filters a post type returned from the REST API.
*
* Allows modification of the post type data right before it is returned.
*
* @since 4.7.0
*
* @param WP_REST_Response $response The response object.
* @param WP_Post_Type $post_type The original post type object.
* @param WP_REST_Request $request Request used to generate the response.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
Related Hooks
Related hooks will be displayed here in future updates.