WP HOOKS
filtrdynamicznyod 4.7.0

rest_{$this->post_type}_query

Args 2Plik wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

Opis — z kodu źródłowego

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.

Hook dynamiczny — możliwe nazwy

rest_attachment_queryrest_page_queryrest_post_query

Parametry

ParametrTypOpis
$argsarrayArray of arguments for WP_Query.
$request\WP_REST_RequestThe REST API request.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'rest_{$this->post_type}_query', 'twoja_funkcja', 10, 2 );

function twoja_funkcja($param_1, $param_2) {
	// Twój kod
}

Popularne w tej kategorii