WordPress Ajax Numbered Pagination in 5 minutes

As we know that in the current era, everyone is looking for the websites with minimum number of refresh. One of the solution for that is “Ajax”. We consider that you already have basic knowledge of how to use Ajax in wordPress. So lets start with “wordPress Ajax Numbered Pagination in 5 minutes”

Step 1: Creating Ajax function for WordPress Ajax Numbered Pagination

First of all, we have to create an Ajax function which we will call to load the content without refreshing the page. Use the following code and put it in your theme’s functions.php file.

4 minutes left…

Step 2: Making structure to append data

Now we need to make the layout where we will actually append the response from our ajax function. You can do this in two ways:
1) Using shortcode.
2) By making the template.

In this tutorial, we are using the first way i.e Using shortcode because using this way, you can reuse the same shortcode again on a different page for another Ajaxified pagination. Paste the following code again into your theme’s functions.php file.

2 minutes left…

Step 3: Make a script to load the content using ajax – On Page load

Now we have to make a script to load the content using ajax. For that, simply paste the following code into your theme’s footer.php file or you can make a custom script file and enqueue that script into your theme.

1 minute left…

Step 4: Styling the pagination

This is an optional step if you are a developer and want the designer to do the rest of the work on pagination to make it more attractive. If not just use the basic design for pagination and put the following code into your theme’s style.css file.

Time up and you are ready with the WordPress Ajax Numbered Pagination in 5 minutes.

If you have any queries, you can ask a question in our Questionsbank section by clicking here.

Loading