Using AJAX Pagination

This time we’re going to create a simple “Load More” button with ajax. There won’t be any automatic scrolling yet(soon in my future tutorials).

This was an original answer from StackOverflow. Credits to the person who provided this wonderful solution.

First let’s start with creating the shortcode to display the blog posts. This will be a regular loop and using “post” as the post type.

Next we need the ajax script. We’re going to hook it inside “wp_head”.

Finally the ajax hook in order for this snippet to work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.