



Hello, Friend's in this post we are creating a custom code of Pagination in WordPress. It is very easy to put this code any custom template pages. This code is not only for next or prev this code is showing a number, next, prev.





<?php

if ( get_query_var('paged') ) {

$paged = get_query_var('paged');

}

elseif ( get_query_var('page') )

{ // 'page' is used instead of 'paged' on Static Front Page

$paged = get_query_var('page');

} else {

$paged = 1;

}

$custom_query_args = array(

'post_type' => 'offers', // Put Post Name

'posts_per_page' => get_option('posts_per_page'),

'paged' => $paged,

'post_status' => 'publish',

'ignore_sticky_posts' => true,

'category_name' => 'custom-cat',

'order' => 'DESC', 'ASC'

'orderby' => 'date' modified | title | name | ID | rand

);

$custom_query = new WP_Query( $custom_query_args );

if ( $custom_query->have_posts() ) :

while( $custom_query->have_posts() ) : $custom_query->the_post();





$feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?> // get the Feature Image





<?php post_class(); ?>>





<?php

endwhile;

echo paginate_links(array(

'total' => $custom_query-> max_num_pages // Put the this code where you want to show No of pagination

));

endif; ?>