WP_REST_Controller::get_collection_params(): array

In this article

Retrieves the query params for the collections.

Return

array Query parameters for the collection.

Source

public function get_collection_params() {
	return array(
		'context'  => $this->get_context_param(),
		'page'     => array(
			'description'       => __( 'Current page of the collection.' ),
			'type'              => 'integer',
			'default'           => 1,
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
			'minimum'           => 1,
		),
		'per_page' => array(
			'description'       => __( 'Maximum number of items to be returned in result set.' ),
			'type'              => 'integer',
			'default'           => 10,
			'minimum'           => 1,
			'maximum'           => 100,
			'sanitize_callback' => 'absint',
			'validate_callback' => 'rest_validate_request_arg',
		),
		'search'   => array(
			'description'       => __( 'Limit results to those matching a string.' ),
			'type'              => 'string',
			'sanitize_callback' => 'sanitize_text_field',
			'validate_callback' => 'rest_validate_request_arg',
		),
	);
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.