-
Notifications
You must be signed in to change notification settings - Fork 655
per_page default should be the same as user set option in admin #2450
Comments
Isn't this easily filterable? |
Personally, I would say the API is fine the way it is regarding this topic. @andrejcremoznik you can use the I do understand that it would be unexpected and is confusing to have the pagination not in sync with your install by default, when using the API. Going to leave this open for discussion until there is a clear consensus. Most likely I imagine the API will remain as is on this issue. |
I'm not saying this is an issue, I'm trying to argue that following a global user setting should be preferable. To add some more context, this topic is irrelevant to off-site apps that are interfacing with some WP API somewhere on the web. It's only relevant when a template uses the WP API to e.g. replace pagination with lazy loading. Right now I have to create a global JS variable with the value of posts per page setting and inline it in template so that I have the setting's value available in my JS app. @BE-Webdesign what is |
Just a sidenote: Have a look into |
@websupporter no, I'm using |
@andrejcremoznik a right, this exists too :D |
This is a filter that you can hook into so that if you want to respect |
Is there a reference of all the filters available or do I have to read the source? Also, thanks. |
_ |
Not yet, there should be soon I have one in a PR for the docs site, but I am not sure if people want to use it. |
@BE-Webdesign
I am not quite sure about the usage of the global Some context The filter-users (imagine a theme and a plugin want to use a specific amount of posts for theire specific requests and do not want to do it via parameter) would still battle each other, but please leave the parameter-users out of this :D The API is also for applications outside of the current WP system. There are applications, who do not have access to these filters and they want to rely on some things like "I did send this parameter". |
I definitely agree with what you are saying, but if you were in a controlled environment you could use the filter, or you might as well not have the filter at all because it will do it for any params. Open up an issue that is separate from this if you believe the filter would lead to adoption of bad practices so there can be discussion about it. |
Yes, if you are "This is my website, I do what I want" I really have no problem. But If you are like "I write the coolest plugin, put it on wordpress.org and get 100.000 downloads", this is my concern. I will open another issue for this. Thanks :) |
Yeah, I definitely think it is worth discussing because it could lead to strange things. |
Apologies to @andrejcremoznik for polluting your ticket. |
No worries it's an interesting discussion. I agree that this Back on topic; I still think the default shouldn't be 10 but the user set option. External devs using the API will know how to get the right results for their app and theme/plugin devs will save some time and won't break the API by using the filter "incorrectly" and overriding |
We came to the decision a while back that the |
per_page
is currently set to 10.This needlessly complicates things when you want to fetch a paged archive. Instead of simply sending the page you want, you need to either supply
{ per_page: <?= get_option('posts_per_page') ?>, page: N }
or fiddle with theafter
parameter.I think
per_page
should be the same asget_option('posts_per_page')
and not hardcoded to 10.The text was updated successfully, but these errors were encountered: