Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#42947 new defect (bug)

REST API wrong total pages

Reported by: elvishp2006 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.1
Component: REST API Keywords: has-screenshots
Focuses: rest-api Cc:


When I require posts with the draft status the 'x-wp-total' and 'x-wp-totalpages' headers come with extra values ​​being that not all drafts are from the user making a request, so when I try to pick up the second page the answer comes empty.


Change History (5)

#1 @elvishp2006
2 years ago

  • Keywords has-screenshots added

This ticket was mentioned in Slack in #core-restapi by schlessera. View the logs.

2 years ago

#3 @schlessera
2 years ago

To make this work, I think WP would need to make two separate queries when checking for draft posts and published posts at the same time.

So, the logic would be:

If status includes draft:

  • remove draft from status and run query
  • run second query for draft status where the author is the current user
  • sum the count of both queries

@timothyblynjacobs mentioned that this might not work as expected due to capability checks, though.

#4 @wongalex
14 months ago

I can take a look at this as my first real bug and get a diff for the above out (assuming, everything functions and it fixes the total pages).

#5 @TimothyBlynJacobs
3 months ago

#49187 was marked as a duplicate.

Note: See TracTickets for help on using tickets.