WP_REST_Search_Handler::prepare_item() WordPress Method
This method is used to prepare an individual item for search results. It is used to setup the title, excerpt, and permalink for each search result.
WP_REST_Search_Handler::prepare_item( int|string $id, array $fields ) #
Prepares the search result for a given ID.
Contents
Parameters
- $id
(int|string)(Required)Item ID.
- $fields
(array)(Required)Fields to include for the item.
Return
(array) Associative array containing all fields for the item.
Source
File: wp-includes/rest-api/search/class-wp-rest-search-handler.php
abstract public function prepare_item( $id, array $fields );
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.6.0 | The $id parameter can accept a string. |
5.0.0 | Introduced. |