Filter hook 'rest_prepare_taxonomy'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php at line 301

View Source

rest_prepare_taxonomy

Filter Hook
Description
Filters a taxonomy returned from the REST API. Allows modification of the taxonomy data right before it is returned.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php View on GitHub
Hook Type Filter
Line Number 301

Hook Parameters

Type Name Description
WP_REST_Response $response The response object.
WP_Taxonomy $item The original taxonomy object.
WP_REST_Request $request Request used to generate the response.

Usage Examples

Basic Usage
<?php
// Hook into rest_prepare_taxonomy
add_filter('rest_prepare_taxonomy', 'my_custom_filter', 10, 3);

function my_custom_filter($response, $item, $request) {
    // Your custom filtering logic here
    return $response;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php:301 - How this hook is used in WordPress core
<?php
 296  		 *
 297  		 * @param WP_REST_Response $response The response object.
 298  		 * @param WP_Taxonomy      $item     The original taxonomy object.
 299  		 * @param WP_REST_Request  $request  Request used to generate the response.
 300  		 */
 301  		return apply_filters( 'rest_prepare_taxonomy', $response, $taxonomy, $request );
 302  	}
 303  
 304  	/**
 305  	 * Prepares links for the request.
 306  	 *

PHP Documentation

<?php
/**
		 * Filters a taxonomy returned from the REST API.
		 *
		 * Allows modification of the taxonomy data right before it is returned.
		 *
		 * @since 4.7.0
		 *
		 * @param WP_REST_Response $response The response object.
		 * @param WP_Taxonomy      $item     The original taxonomy 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-taxonomies-controller.php
Related Hooks

Related hooks will be displayed here in future updates.