WordPress Pagination Without A Plugin

WordPress Pagination is a basic need for every websites using WordPress platform. There are many pagination plugin available. In this snippet I’m going to show you How to show WordPress Pagination without a Plugin.

Add the following to functions.php in your theme directory:
[php]
if ( ! function_exists( ‘my_pagination’ ) ) :
function my_pagination() {
global $wp_query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ),
‘format’ => ‘?paged=%#%’,
‘current’ => max( 1, get_query_var(‘paged’) ),
‘total’ => $wp_query->max_num_pages
) );
}
endif;
[/php]

Now you can call the function:
[php]

[/php]

View Source →

0 Likes
Maan
Maan

21 year old designer, blogger and front-end developer. love to share creative design and inspiration.

There are 4 comments
  1. So where do you use this? Top of your Blog page with lists of posts? Also, where do you call the function? in page_blog.php?

    • Maan

      First you need to add function in to your theme functions.php and then you need to call the function at the bottom of index.php

    • Ok thanks. I’m not sure where the pagination is supposed to appear though… at the bottom of posts? Could you provide a screenshot? Thanks for replying to my question!

    • Maan

      Go to your theme folder and find this line previous_posts_link and next_posts_link in index.php, archive.php, category.php, search.php and any other archive page template. and replace it with this:

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

div#stuning-header .dfd-stuning-header-bg-container {background-image: url(http://www.downgraf.com/wp-content/uploads/2017/04/login-back.jpg);background-size: cover;background-position: center center;background-attachment: scroll;background-repeat: no-repeat;}#stuning-header div.page-title-inner {min-height: 500px;}