WordPress at Your Fingertips
filter is not described

rest_(post_type)_query filter-hook . WP 4.7.0

Filters WP_Query arguments when querying posts via the REST API.

The dynamic portion of the hook name, $this->post_type, refers to the post type slug.

Possible hook names include:

  • rest_post_query
  • rest_page_query
  • rest_attachment_query

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


add_filter( 'rest_(post_type)_query', 'filter_function_name_2995', 10, 2 );
function filter_function_name_2995( $args, $request ){
	// filter...

	return $args;
Array of arguments for WP_Query.
The REST API request.


Since 4.7.0 Introduced.
Since 5.7.0 Moved after the tax_query query arg is generated.

Where the hook is called

wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 349
$args       = apply_filters( "rest_{$this->post_type}_query", $args, $request );

Where in WP core the hook is used WordPress

Usage not found.