Infinite Scroll Hooks Issue

Hello.

I am currently building an archive page that initially loads 9 posts and then on a press of a button (“Load more”) it will load 9 more posts and so on.

I am using the “usePostTypeInfiniteScroll” for doing it, but I encounter the following issues:

  1. The first 9 posts are loaded correctly and they work as expected, but every time I press Load More, it only loads 1 post, not 9 (yes, I have more than 10 posts).
  2. The Archive page also shows up in the Posts list (how can I remove it?)
  3. Sometimes when I load a few posts and I scroll up or down, the page goes to one of the Posts Pages. How can this be fixed?

Gist containing my component code: Infinite Load Hooks - UsePostTypeInfiniteScroll · GitHub

Thank you! :slight_smile:

Hi @radu

Can you try and change the limit to 10, and test if that works? :slight_smile:

Hi @kasper,

Thanks you for trying to help. The same behaviour happens when the limit is set to 10.

Hi @radu,

I have infinite scroll on this page:

https://arctic-bioscience.com/news/

Here is the gist:

After looking at the code, I also now remember that limit is page numbers, not posts. So 2 or 3 should be a good start.

@kasper The limit you have been implemented is using “useArchiveInfiniteScroll”, not “usePostTypeInfiniteScroll”.

I was trying to use the “usePostTypeInfiniteScroll”, in order to also have the functionality of choosing the archive source.