2 years ago

WordPress Pagination Without A Plugin

Written by
PHP Code Snippets

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:

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
		) );

Now you can call the function:

<?php my_pagination(); ?>

View Source →

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

Comments to WordPress Pagination Without A Plugin

  • 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?

    Marianne January 2, 2014 11:05 pm Reply
    • 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

      Maan January 3, 2014 6:35 pm
    • 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!

      Marianne January 6, 2014 8:41 pm
    • 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:

      Maan January 6, 2014 9:58 pm

Leave a Comment

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

Menu Title