Here’s the original answer.
To sum it up briefly:
- Build a custom plugin
- Register a custom script
- Localize this script to add the data from
$GLOBALS['wp_query']
–numberposts
,posts_per_page
andfound_posts
in it. - Write a custom event handler that triggers when the infinite scroll function runs.