rest_prepare_category filter-hookWP 4.7.0

Filters the term data for a REST API response.

Allows modification of the term data right before it is returned.

This is one of the variants of the dynamic hook rest_prepare_(taxonomy)

Usage

add_filter( 'rest_prepare_category', 'wp_kama_rest_prepare_category_filter', 10, 3 );

/**
 * Function for `rest_prepare_category` filter-hook.
 * 
 * @param WP_REST_Response $response The response object.
 * @param WP_Term          $item     The original term object.
 * @param WP_REST_Request  $request  Request used to generate the response.
 *
 * @return WP_REST_Response
 */
function wp_kama_rest_prepare_category_filter( $response, $item, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$item(WP_Term)
The original term object.
$request(WP_REST_Request)
Request used to generate the response.

Changelog

Since 4.7.0 Introduced.

Where the hook is called

WP_REST_Terms_Controller::prepare_item_for_response()
rest_prepare_category
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php 882
return apply_filters( "rest_prepare_{$this->taxonomy}", $response, $item, $request );

Where the hook is used in WordPress

Usage not found.