WordPress.org

WordPRess GSoC Trac

Opened 11 months ago

Closed 7 months ago

Last modified 7 months ago

#266 closed enhancement (fixed)

Enable collection pagination

Reported by: rmccue Owned by: rmccue
Milestone: 2013 Midterm (Beta) Priority: major
Component: JSON REST API Keywords:
Cc: prettyboymp

Description

Tracking ticket for week 4.

Change History (9)

comment:1 rmccue11 months ago

  • Type changed from defect to enhancement

comment:2 bpetty10 months ago

  • Milestone set to 2013 Midterm (Beta)

comment:3 prettyboymp10 months ago

  • Cc prettyboymp added

comment:4 rmccue10 months ago

In 2083:

Add better pagination tools

See #266, #267, #268

comment:5 rmccue10 months ago

In 2084:

Allow always passing in posts_per_page

See #266

comment:6 follow-up: bpetty9 months ago

I see posts_per_page, and page, but I'm not currently seeing any value indication in the schema for total number of items in a paged collection. I know some REST APIs will include a "last" link header, leaving it open for some parsing and calculations to get the total number of items. I still would like to see a total count somewhere else not requiring extra URL parsing, but I'm not sure where the best place for this would be honestly.

comment:7 in reply to: ↑ 6 rmccue9 months ago

Replying to bpetty:

I see posts_per_page, and page, but I'm not currently seeing any value indication in the schema for total number of items in a paged collection. I know some REST APIs will include a "last" link header, leaving it open for some parsing and calculations to get the total number of items. I still would like to see a total count somewhere else not requiring extra URL parsing, but I'm not sure where the best place for this would be honestly.

Ah, whoops! This should be in query_navigation_headers() with the next/previous links. Agreed on the "last" header. Most likely, an X-WP-Total header would be the best option for a proper count.

(Just to head off any comments: While X- headers are deprecated for things likely to make it into standards, they're still fine to use for vendor-specific headers.)

comment:8 rmccue7 months ago

  • Resolution set to fixed
  • Status changed from new to closed

In 2291:

Add header for the number of total pages

Fixes #266

comment:9 rmccue7 months ago

In 2293:

Send X-WP-Total with the total number of posts

See #266

Note: See TracTickets for help on using tickets.