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.

Read Also:  Laravel 5.7 REST API Tutorial Example Steps

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

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.

Read Also:  jQuery AJAX Inline Insert Update Delete using PHP MySQL

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Multiple checkbox in php Example with Demo
  2. Read Also:  javascript capitalize first letter of each word
  3. Read Also:  Smooth Scroll to Top with jQuery
  4. Read Also:  Integration with Pagination Without WordPress Plugins
  5. Read Also:  jQuery Back to top
  6. Read Also:  jquery reload page Automatically Example
  7. Read Also:  Laravel 6 Delete File from public folder Example
  8. Read Also:  how to send attachment in mail in php?
  9. Read Also:  Simple JQuery Preloader With CSS And Image
  10. Read Also:  Laravel 6 Delete File from public folder Example
CLOSEX