wppaste
WordPress

apply_filters( 'rest_post_search_query', array $query_args, WP_REST_Request $request )

Since
5.1.0
Filters the query arguments for a REST API post search request.

Description

Enables adding extra arguments or setting defaults for a post search request.

Compatibility

WordPress
since 5.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$query_argsarray
Key value array of query var to query value.
$requestWP_REST_Request
The request used.

Where this hook fires · 1

  • wp-includes/rest-api/search/class-wp-rest-post-search-handler.php:93WP_REST_Post_Search_Handler::search_items()

Source code

		 *		 * @since 5.1.0		 *		 * @param array           $query_args Key value array of query var to query value.		 * @param WP_REST_Request $request    The request used.		 */		$query_args = apply_filters( 'rest_post_search_query', $query_args, $request ); 		$query = new WP_Query();		$posts = $query->query( $query_args );		// Querying the whole post object will warm the object cache, avoiding an extra query per result.		$found_ids = wp_list_pluck( $posts, 'ID' );		$total     = $query->found_posts;

Changelog

Introduced in 5.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.