WordPress.org

Make WordPress Core

#49187 closed defect (bug) (duplicate)

WordPress REST API incorrect pagination

Reported by: akshayshah Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords:
Focuses: Cc:

Description

The header x-wp-total value is inconsistent with the actual number of objects in the payload for some cases
See screenshot/attachment

ubuntu@wordpress:~$ python3
Python 3.6.8 (default, Oct  7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json, requests
>>> response = requests.get("http://WORDPRESS_IP/wp-json/wp/v2/media", params={"per_page": 100, "page": 1})
>>> int(response.headers.get("x-wp-total"))
67
>>> len(response.json())
66

Change History (1)

#1 @TimothyBlynJacobs
23 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version changed from 5.3.2 to 4.7

Hi @akshayshah,

Thanks for the ticket and welcome to trac!

We are already tracking this issue in #42947.

Note: See TracTickets for help on using tickets.