wordpress pagination example

Today, We want to share with you wordpress pagination example.In this post we will show you wordpress custom pagination function, hear for wordpress pagination custom query we will give you demo and example for implement.In this post, we will learn about Integration with Pagination Without WordPress Plugins with an example.

How to Add Numeric Pagination in Your WordPress Theme

In this tutorial we learn to all about wordpress pagination example Examples like as a wordpress pagination custom query, with numbers, code for posts, custom pagination function, pagination links, with foreach loop and custom template or many more.

Free Live Chat for Any Issue

The function: Add Numeric Pagination

function pakainfo_numeric_posts_nav() {
 
    if( is_singular() )
        return;
 
    global $wp_query;
    if( $wp_query->max_num_pages <= 1 )
        return;
 
    $moreload = get_query_var( 'moreload' ) ? absint( get_query_var( 'moreload' ) ) : 1;
    $max   = intval( $wp_query->max_num_pages );
 
    if ( $moreload >= 1 )
        $navurls[] = $moreload;
 
    if ( $moreload >= 3 ) {
        $navurls[] = $moreload - 1;
        $navurls[] = $moreload - 2;
    }
 
    if ( ( $moreload + 2 ) <= $max ) {
        $navurls[] = $moreload + 2;
        $navurls[] = $moreload + 1;
    }
 
    echo '<div class="navigation"><ul>' . "\n";
 
    if ( get_previous_posts_link() )
        printf( '<li>%s</li>' . "\n", get_previous_posts_link() );
 
    if ( ! in_array( 1, $navurls ) ) {
        $class = 1 == $moreload ? ' class="active"' : '';
 
        printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
 
        if ( ! in_array( 2, $navurls ) )
            echo '<li>…</li>';
    }
 
    sort( $navurls );
    foreach ( (array) $navurls as $link ) {
        $class = $moreload == $link ? ' class="active"' : '';
        printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
    }
 

    if ( ! in_array( $max, $navurls ) ) {
        if ( ! in_array( $max - 1, $navurls ) )
            echo '<li>…</li>' . "\n";
 
        $class = $moreload == $max ? ' class="active"' : '';
        printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
    }
 
    if ( get_next_posts_link() )
        printf( '<li>%s</li>' . "\n", get_next_posts_link() );
 
    echo '</ul></div>' . "\n";
 
}

Added WordPress Pagination

How to use & Step by Step description?

<?php pakainfo_numeric_posts_nav(); ?>

CSS Code

.navigation li a,
.navigation li a:hover,
.navigation li.active a,
.navigation li.disabled {
    color: #fff;
    text-decoration:none;
}
 
.navigation li {
    display: inline;
}
 
.navigation li a,
.navigation li a:hover,
.navigation li.active a,
.navigation li.disabled {
    background-color: #6FB7E9;
    border-radius: 3px;
    cursor: pointer;
    padding: 12px;
    padding: 0.75rem;
}
 
.navigation li a:hover,
.navigation li.active a {
    background-color: #3C8DC5;
}

Download

I hope you get an idea about wordpress pagination example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.