Developer reference

Where it runs

The plugin hooks render_block_core/post-template. The first Post Template whose Query block inherits the main query, on a request that is not singular, admin or REST, gets the class lh-infinite-scroll-items on its list element. When the main query has a later page, the list also gets data-lh-infinite-scroll-next with that page’s URL (from get_pagenum_link(), so query strings such as a search term are kept), and the script is enqueued. Query blocks with their own custom query are left alone, and so are classic PHP templates.

In the browser

Events

lh-infinite-scroll:loaded bubbles from the list after each page is appended, with detail.url, detail.title and detail.nextUrl (empty after the last page). Use it to start anything that needs to act on the new items.

Filters

The script reads its settings from window.lhInfiniteScrollSettings (distance, and the translated loaded and failed messages), printed before it.