rest_{$this->post_type}_query WordPress Filter Hook

The rest_{$this->post_type}_query hook is used to modify the WP_Query object before it is executed. This is useful for modifying the query arguments, or for adding extra security checks.

apply_filters( "rest_{$this->post_type}_query", array $args, WP_REST_Request $request ) #

Filters WP_Query arguments when querying posts via the REST API.


Description

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.


Top ↑

Parameters

$args

(array)Array of arguments for WP_Query.

$request

(WP_REST_Request)The REST API request.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

View on Trac



Top ↑

Changelog

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

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.