Wordpress theme pagination headache
May 7, 2017 8:18 AM   Subscribe

I bought a custom wordpress theme and have edited it substantially. I love it except the way it handles 'Show More Posts' pagination on the front page. At the moment it loads a whole new page of posts, but I would prefer it if it just added the following posts to the end of the current page. How can I acheive this?

You can find a link to the site in question at my profile.

The front page portfolio view loads 20 posts. There is a 'Load More' button at the bottom. Pressing this opens 'Page 2' with the following 20 posts only showing.

How can I change this to add these posts to the end of the original page instead? It may be possible with an entirely different integration - maybe Infinite Scrolling - than the one currently.

Here is the html / wordpress code it uses to paginate the page.
posted by 0bvious to Computers & Internet (4 answers total) 1 user marked this as a favorite
You need to make an AJAX call via JavaScript and populate the page you're on by appending the results returned from the AJAX call to the end of the page. You can use the WP REST API for the AJAX endpoint, and there is probably a plugin that will extend the API to enable the kind of functionality you're thinking of, if you don't have the JS/PHP know-how to DIY. See here, for instance: https://wordpress.org/plugins/ajax-load-more-rest-api/. If you do want to DIY, here's a decent tutorial (the example code fetches posts from some other site, but is adapatable to what you want to do.)
posted by eustacescrubb at 8:44 AM on May 7, 2017

Response by poster: thanks @eustacescrubb... does this plugin do what you mention?
posted by 0bvious at 9:07 AM on May 7, 2017

Looks like it does except that the trigger to load more posts is reaching the end of the page rather than clicking a button.
posted by eustacescrubb at 9:18 AM on May 7, 2017

Seems this is what you need (option in the same plugin): pause loading.
posted by wolfr at 1:42 PM on May 7, 2017

« Older Give me a leg up! (smoked, cured)   |   Photography tips for photographing illustrations... Newer »
This thread is closed to new comments.