Querying a large per_page number of posts
pycal opened this issue · 3 comments
I'm noticing that when I set my per_page param to a number exceeding 100, I will still only be able to retrieve 100 objects (in my case I am expecting around 200).
Sidenote: I've noticed that the per_page param isn't working as described in the docs - I can set per_page > MAX_POSTS_PER_PAGE.
Quoting the doc:
"The maximum number of posts to return. The value must range from 1 to MAX_POSTS_PER_PAGE."
So I've found a solution for my particular problem.
Something like this will only ever return a max of 100 objects (despite my MAX_POSTS_PER_PAGE being set to 500):
/wp_api/v1/posts?per_page=500&post_type=glossary
However this will return all objects in the post_type I am querying:
/wp_api/v1/posts?per_page=-1&post_type=glossary
When you are defining MAX_POSTS_PER_PAGE
, are you defining it with the appropriate namespace?
It should be \Voce\Thermal\v1\MAX_POSTS_PER_PAGE
I was not able to replicate the issue you stated of being able to query with and return more results than what is set for MAX_POSTS_PER_PAGE
. I could specify 200 but since the default for MAX_POSTS_PER_PAGE
is 100, that is the max. Once I changed the value for \Voce\Thermal\v1\MAX_POSTS_PER_PAGE
I am being returned the correct result set.
I'm still not able to replicate issue here and without any response from the user, I am closing this issue.
If needed, please comment on the issue and we can re-open it or open a new issue.