How to Create Simple WordPress (Pagination) Without Plugins

There is a number of WordPress theme, you can choose and apply to your project, on that time don’t research more about the feature, the result is no Pagination option as well no other option like author box, already make the author bio box without a plugin.

Let me tell you how to create simple pagination with the number in WordPress post without having any plugin. There are lots of developers who actually didn’t know how to use pagination in WordPress posts. Some people are in this case using a plugin for WordPress posts pagination but they didn’t realize that plugin makes website heavy. Let’s start with code reference.

How to Create Simple WordPress Pagination no Plugins

Step-1 Add Specific Code

All you have to do is add this code to your theme’s function.php file and want to copy/paste into your theme file;

If you don’t know how to find function.php then go to log in to your Dashboard → Theme → Appearance → Theme Editor, after clicking on Theme Editor on the right side all Theme Files name find function.php click and open, at last line you add this code mention below:

Select the Theme Function
function pagination($prev = '«', $next = '»') {
    global $wp_query, $wp_rewrite;
    $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
    $pagination = array(
        'base' => @add_query_arg('paged','%#%'),
        'format' => '',
        'total' => $wp_query->max_num_pages,
        'current' => $current,
        'prev_text' => __($prev),
        'next_text' => __($next),
        'type' => 'plain'
    if( $wp_rewrite->using_permalinks() )
        $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
    if( !empty($wp_query->query_vars['s']) )
        $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
    echo paginate_links( $pagination );

Step – 2 Display the Pagination

After doing this call the pagination function where you want to display the pagination. on your post page, using the pagination(). function. You can add it somewhere outside the loop, but inside the if( have_post() ) statement of your template file. Dashboard → Theme → Appearance → Theme Editor → single.php (Single Post).


Now, you are inside the single.php file paste the code on the end tag /main above.

<?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
        // post goes here
    <?php endwhile; ?>
    <div class="pagination"><?php pagination('»', '«'); ?></div>
<?php endif; ?>

Step – 3 Style CSS Design Pagination

WordPress also enables you to add custom CSS classes that you can use to manage the look of your new navigation. See this CSS example to figure out how to style it:

Dashboard → Theme → Appearance → Theme Editor → style.css (same page open) add this code at last line where end.

.page-numbers { font-size: 15px; }
.page-numbers.current { color: #222; }
.page-numbers .dots { letter-spacing: 1px }  { font-size: 14px; color: #3888ff; }

By using these all three steps mention above you can get pagination for WordPress posts without any plugin and your website will be load free. I hope this tutorial will be helpful to you, If you liked this code snippet, want more SEO friendly to so please consider checking out our other articles on the site like Active all image title tag only one step and Manually Add Structured Data WordPress Without Plugin Schema Markup.

Other Popular Articles...

Leave a Comment