Support

Account

Home Forums Add-ons Gallery Field "Infinite scroll" for an ACF Gallery page?

Solving

"Infinite scroll" for an ACF Gallery page?

  • I have a page based on a custom template I’ve written that does a simple loop through the ACF Gallery data structure and renders out a thumbnail gallery. Responsive.

    I need to have it load only x number of images and then load y number more and then load y number more, etc. as page is scrolled down. Hundreds of thumbs. Don’t want to use a pager.

    I think JetPack Infinite Scroll doesn’t work in this scenario, and I am not sure LazyLoad jQuery is the ticket here either. Can someone advise how I may want to go on this?

    Thanks.

    bp

  • I don’t know if such a thing exists. What you need is a plugin that will do the infinite scroll and allow you to choose a custom template for outputting the results.

    Short of that you’d need to write your own script to detect when the user scrolls near the bottom of the page an make an AJAX call to get the next results. The best information on using AJAX in WP can be found here https://codex.wordpress.org/AJAX_in_Plugins

  • It turns out there has been a decision change. Now standard pagination is needed. Still something I need to figure out…

    bp

  • When you say,

    .. that does a simple loop through the ACF Gallery data structure and renders out a thumbnail gallery.

    makes me think you’re doing something outside of what a standard WP loop would do, so also outside any type of standard pagination that could be used, so it’s going to need to be custom built.

    As an alternate, and this is just a suggestion to think about, Don’t know how far you are into this thing, and it might be too far along to change plans, but, I would use a custom post type with an archive, use pre_get_posts to set up how many to show, and then use standard WP pagination and let WP take care of the details.

  • I’m way late here, but in case anyone needs this – I built a plugin for this.
    https://wordpress.org/plugins/ajax-load-more-for-acf/

    Hope it helps others.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘"Infinite scroll" for an ACF Gallery page?’ is closed to new replies.