wp_rest_search_handlers
Filter HookDescription
Filters the search handlers to use in the REST search controller.Hook Information
File Location |
wp-includes/rest-api.php
View on GitHub
|
Hook Type | Filter |
Line Number | 342 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$search_handlers
|
List of search handlers to use in the controller. Each search handler instance must extend the `WP_REST_Search_Handler` class. Default is only a handler for posts. |
Usage Examples
Basic Usage
<?php
// Hook into wp_rest_search_handlers
add_filter('wp_rest_search_handlers', 'my_custom_filter', 10, 1);
function my_custom_filter($search_handlers) {
// Your custom filtering logic here
return $search_handlers;
}
Source Code Context
wp-includes/rest-api.php:342
- How this hook is used in WordPress core
<?php
337 *
338 * @param array $search_handlers List of search handlers to use in the controller. Each search
339 * handler instance must extend the `WP_REST_Search_Handler` class.
340 * Default is only a handler for posts.
341 */
342 $search_handlers = apply_filters( 'wp_rest_search_handlers', $search_handlers );
343
344 $controller = new WP_REST_Search_Controller( $search_handlers );
345 $controller->register_routes();
346
347 // Block Renderer.
PHP Documentation
<?php
/**
* Filters the search handlers to use in the REST search controller.
*
* @since 5.0.0
*
* @param array $search_handlers List of search handlers to use in the controller. Each search
* handler instance must extend the `WP_REST_Search_Handler` class.
* Default is only a handler for posts.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/rest-api.php
Related Hooks
Related hooks will be displayed here in future updates.