The team is now working on the WordPress Interactivity API. This unblocks the same UX Frontity framework enabled but directly in WordPress Core, fully compatible with the new Site Editor.
I have set the number of posts to 9 here, but I still fetches 10. How do I solve this?
juanma3
Hi @kasper,
That setting in the Admin Reading Settings only determines the number of posts shown using a traditional PHP-based theme. It doesn’t affect what is returned in the WP REST API.
To control how many posts are displayed on each page I think you need to add the per_page parameter to the request. See here for more info.
juanma8
I think to be able to use the Infinite Scroll hooks here, the solution goes through the creation of a handler that performs a custom request by using the low-level method libraries.source.api.get() which allows to specify params such as per_page fro the request
@cristianbote Any idea how to combine a custom handler that return a custom number of elements per archive page with an Infinite Scroll hook such as useArchiveInfiniteScroll ?
cristianbote9
Hey @juanma, was looking into it but fell short of a code solution. Gonna ask @David for his opinion on this one.
So, @David, what are our thoughts? Can you combine the useArchiveInfiniteScroll with a custom handler to have custom pagination?
David10
It should be possible, because useArchiveInfiniteScroll works with links and uses the next property of archive data objects to get the next link, whatever the number of posts of each archive page.
Hey @juanma, another option would be specifying per_page for all the REST API requests using the state.source.param property, though that would change the number of posts for all archives.