How to Make Page Numbers or Pagination in WordPress

The pagination design pattern is widely used on websites that require a lot of content to be shared on a page. The use of pagination has been used on various sites, from search engines like Google, Bing, Yahoo to e-commerce sites such as Tokopedia, Shopee and Bukalapak.

Pagination itself is a feature to divide website content into several pages to make it easier for visitors to navigate. The purpose of this pagination is so that the website loading does not take long. Imagine if a website has a total of thousands of content if there is no pagination once we visit the website it is immediately loaded at once without pagination and the impact of loading will take a very long time.

In this article, Yiptechid will share how to make Pagination on WordPress, follow the steps below.

How to Make Pagination on WordPress

1. Manual Method

If you’re creating your own theme, or want to add pagination to your theme, you can do this by using WordPress’ built-in functionality and adding a few lines of code to the theme’s functions.php file you’re currently using. Open your functions.php file, and scroll down, then add this code:

function pagination_bar() {
    global $wp_query;
    $total_pages = $wp_query->max_num_pages;
    if ($total_pages > 1){
        $current_page = max(1, get_query_var('paged'));
        echo paginate_links(array(
            'base' => get_pagenum_link(1) . '%_%',
            'format' => '/page/%#%',
            'current' => $current_page,
            'total' => $total_pages,

Next add the code below, in the usual files (index.php and archive.php) and paste the following code before the end of the loop of the “endif” statement, but before “endwhile”.

<Nav class = "pagination">
<? Php pagination_bar (); ?>
</ Nav>

After all you follow the steps above, you will see the results as shown below.

2. Using the WP-PageNavi Plugin

If you don’t want to use the manual method which is a little more difficult, there are several plugins that can help you add a Page number. You can use the WP-PageNavi plugin which is easy to use and customize. You can read the tutorial on centerklik on how to use the Wp-PageNavi plugin.

Here’s how to customize it

  • Go to menu Appearance> Theme editor.
  • Select a web page file, for example index.php, archive.php or category.php.
  • Look for the following line of code:

(this is the twentyten theme if you use another theme maybe the script will be a little different)

<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>

<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div> 
  • Replace the code with the following line of code:
<?php wp_pagenavi(); ?>
  • After adding the code, save changes and see the results

That’s how to make pagination in WordPress, Hopefully useful

Leave a Reply

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