LLMS_REST_Posts_Controller::map_params_to_query_args( array $prepared, array $registered, WP_REST_Request $request )

Map schema to query arguments to retrieve a collection of objects.

Parameters Parameters


(array) (Required) Array of collection arguments.


(array) (Required) Registered collection params.


(WP_REST_Request) (Required) Full details about the request.

Top ↑

Return Return


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php

	protected function map_params_to_query_args( $prepared, $registered, $request ) {

		$args = array();

		* This array defines mappings between public API query parameters whose
		* values are accepted as-passed, and their internal WP_Query parameter
		* name equivalents (some are the same). Only values which are also
		* present in $registered will be set.
		$parameter_mappings = array(
			'order'   => 'order',
			'orderby' => 'orderby',
			'page'    => 'paged',
			'exclude' => 'post__not_in',
			'include' => 'post__in',
			'search'  => 's',
			'status'  => 'post_status',

		* For each known parameter which is both registered and present in the request,
		* set the parameter's value on the query $args.
		foreach ( $parameter_mappings as $api_param => $wp_param ) {
			if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) {
				$args[ $wp_param ] = $request[ $api_param ];

		// Ensure our per_page parameter overrides any provided posts_per_page filter.
		if ( isset( $registered['per_page'] ) ) {
			$args['posts_per_page'] = $request['per_page'];

		return $args;

Top ↑

Changelog Changelog

Version Description
1.0.0-beta.19 Map 'status' collection param to to 'post_status' query arg.
1.0.0-beta.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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