Code Snippets

WordPress Pagination Without A Plugin

Maan
Jan 1, 2014
1 min read
105 words

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 →Country Drop Down List for Web Forms

Maan

Author

Maan is a Lead Frontend Engineer and Creative Director with 10+ years of industry experience blending UI/UX design with React-based development. A multifaceted practitioner, he has spent a decade turning abstract inspiration into deployed, scalable reality. Maan’s expertise lies in high-fidelity prototyping and component architecture, which he shares through insightful technical writing with the next generation of developers. His unique approach ensures that pixels not only meet passion but also rigorous performance standards.

View all posts

Continue reading

You might also like

4 responses to “WordPress Pagination Without A Plugin”

  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?

    1. 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

    2. 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!

    3. 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:

Leave a Reply

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

Menu