LLMS_REST_Users_Controller::get_pagination_data_from_query( WP_User_Query $query, array $prepared, WP_REST_Request $request )

Retrieve pagination information from an objects query.

Parameters Parameters


(WP_User_Query) (Required) Objects query result returned by LLMS_REST_Users_Controller::get_objects_query().


(array) (Required) Array of collection arguments.


(WP_REST_Request) (Required) Request object.

Top ↑

Return Return

(array) Array of pagination information.

  • 'current_page'
    (int) Current page number.
  • 'total_results'
    (int) Total number of results.
  • 'total_pages'
    (int) Total number of results pages.

Top ↑

Source Source

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

	protected function get_pagination_data_from_query( $query, $prepared, $request ) {

		$current_page  = absint( $prepared['page'] );
		$total_results = $query->get_total();
		$total_pages   = absint( ceil( $total_results / $prepared['per_page'] ) );

		return compact( 'current_page', 'total_results', 'total_pages' );


Top ↑

Changelog Changelog

Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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