Archived topic
How activate infinite scroll for custom post type
5 replies · Started by Sebastian on April 4, 2022
Hey guys,
I have custom post type posts displaying in a section on my homepage (as cards in a custom 2 col layout). I solved that by using a hook with a wp_query, querying them all and then inserting it on the page with generate_before_main_content hook. I would like to enable infinite scroll for these because the amount of posts will most probably vary quite some.
This is the simple query I'm using:
<?php
$homepageAdvisors = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'radgivare'
));
?>
Please tell me there is a simple way of making this work? :)
Thanks!
Hi there,
the GP infinite scroll is built upon the paging navigation used on the archive templates.
It cannot be simply used for a custom loop that is hooked into a page. You would need to find a custom solution for that which isn't simple. Bill Erickson provides a method here:
https://www.billerickson.net/infinite-scroll-in-wordpress/
You may want to consider finding a plugin to do it instead though.
Ok, thanks for your input! I dug around and found "Ajax Load More" plugin which after some css tweaking does exactly what I want.
However, I am a bit worried that this kind of implementation (placing content solely with the help of Ajax) will ruin the SEO for the page (or section at least). I'm not good at javascript, so David, what do you think about that? (Sorry for jumping around topics here)
Maybe this article will calm any fears:
https://searchengineland.com/google-can-crawl-ajax-just-fine-322254
Thanks a lot!! Yes that is calming to read :)
Glad to hear that!