custom pagination gives 404 page

I am working on custom pagination in custom post type in wordpress.
the code I have used

in function.php

function custom_pagination($numpages = ”, $pagerange = ”, $paged=”) {

if (empty($pagerange)) {
$pagerange = 2;
}

global $paged;

if (empty($paged)) {
$paged = 1;
}

if ($numpages == ”) {
global $wp_query;

$numpages = $wp_query->max_num_pages;

if(!$numpages) {
$numpages = 1;
}
}

$pagination_args = array(
‘base’ => get_pagenum_link(1) . ‘%_%’,
‘format’ => ‘page/%#%’,
‘total’ => $numpages,
‘current’ => $paged,
‘show_all’ => False,
‘end_size’ => 1,
‘mid_size’ => $pagerange,
‘prev_next’ => True,
‘prev_text’ => __(‘«’),
‘next_text’ => __(‘»’),
‘type’ => ‘plain’,
‘add_args’ => false,
‘add_fragment’ => ”
);

$paginate_links = paginate_links($pagination_args);

if ($paginate_links) {
echo “<div class=’pagination’>”;
echo “<div class=’left’>Page ” . $paged . ” of ” . $numpages . “</div> “;
echo “<div class=’right’>” . $paginate_links . “</div> “;
echo “</div>”;
}

}

in custom post type page

function cases_list(){
global $post, $theme;
$paged = ( get_query_var(‘paged’) ) ? get_query_var(‘paged’) : 1;

$qry_args = array(
‘post_type’ => ‘cases’,
‘post_status’ => ‘publish’,
‘orderby’ => ‘title’,
‘order’ => ‘ASC’,
‘posts_per_page’ => 8,
‘paged’ => $paged
);

$qry = new WP_Query( $qry_args );
if($qry->have_posts()):

$out = ‘<ul class=”helpList”>’;
$x = 1;
while($qry->have_posts()) : $qry->the_post();
$title = get_the_title();
$id = get_the_ID();
$class = get_the_ID();
$content = get_the_content();
$urlbox = get_url_desc_box_cases();

$out .= “<li>”;

if( $urlbox[1] !=”) {
$out .= “<div class=’sharePan’><span class=’shareBtn’>…</span><div class=’shareDrop’>”.do_shortcode(‘[addtoany]’).”</div></div>”;
}

if( $urlbox[1] !=”) {
$out .= “<div class=’listPostImg’><img src='”. $urlbox[1] .”‘ alt='”.$title.”‘ /></div>”;
}
if( $title !=”) {
$out .= “<div class=’listPostTxt’><h3><a href='”.get_permalink().”‘>”.$title.”</a></h3>”;
}
if( $content !=”) {
$out .= ‘<div class=”featureContent”>’.$content.'</div>’;
}
$out .= “</div></li>”;
$x ++;

endwhile;
$out .= ‘</ul>’;

endif;

wp_reset_postdata();

if (function_exists(custom_pagination)) {
$out .= ‘<div class=”col-sm-12 inner-sm”>’;
$out .= custom_pagination($qry->max_num_pages, “”, $paged);
$out .=”</div>”;
}
return $out;

}

but unfortunately pagination pages gives 404 page.
am i doing any thing wrong.

any help would be greatly appreciated

Read more here:: custom pagination gives 404 page

Leave a Reply

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