bp_rest_response_add_total_headers( WP_REST_Response $response, integer $total, integer $per_page )
Set headers to let the Client Script be aware of the pagination.
Description
Parameters
- $response
-
(Required) The response data.
- $total
-
(Required) The total number of found items.
- $per_page
-
(Required) The number of items per page of results.
Return
(WP_REST_Response) $response The response data.
Source
File: bp-core/bp-core-rest-api.php
function bp_rest_response_add_total_headers( WP_REST_Response $response, $total = 0, $per_page = 0 ) {
if ( ! $total || ! $per_page ) {
return $response;
}
$total_items = (int) $total;
$max_pages = ceil( $total_items / (int) $per_page );
$response->header( 'X-WP-Total', $total_items );
$response->header( 'X-WP-TotalPages', (int) $max_pages );
return $response;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.3.5 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.