index.php
<?php
$cur_page = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1; //get curent page
$offers_per_page = couponxl_get_option( 'offers_per_page' );
$args = array(
'post_type' => 'offer',
'posts_per_page'=> $offers_per_page,
'post_status' => 'publish',
'meta_key' => 'offer_expire',
'orderby' => 'meta_value_num',
'page' => $cur_page,
'order' => 'ASC',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'offer_store',
'value' => get_the_ID(),
'compare' => '='
),
array(
'key' => 'offer_start',
'value' => current_time( 'timestamp' ),
'compare' => '<='
),
array(
'relation' => 'OR',
array(
'key' => 'offer_expire',
'value' => current_time( 'timestamp' ),
'compare' => '>='
),
array(
'key' => 'offer_expire',
'value' => '-1',
'compare' => '='
)
),
array(
'relation' => 'OR',
array(
'key' => 'deal_status',
'value' => 'sold_out',
'compare' => '!='
),
array(
'key' => 'deal_status',
'value' => 'sold_out',
'compare' => 'NOT EXISTS'
),
),
)
);
if( !empty( $offer_type ) ){
$args['meta_query'][] = array(
'key' => 'offer_type',
'value' => $offer_type,
'compare' => '='
);
}
$offers = new WP_Query( $args );
$page_links_total = $offers->max_num_pages;
$pagination_args = array(
'end_size' => 2,
'mid_size' => 2,
'total' => $page_links_total,
'current' => $cur_page,
'prev_next' => false,
'type' => 'array'
);
if( isset( $offer_type ) ){
$pagination_args['format'] = !get_option( 'permalink_structure' ) ? '?page=%#%' : 'page/%#%';
}
$page_links = paginate_links( $pagination_args );
$pagination = couponxl_format_pagination( $page_links );
if( $offers->have_posts() ){
$col = 6;
if( $offer_view == 'list' ){
$col = 12;
}
?>
<?php if( !empty( $pagination ) ): ?>
<div class="col-sm-<?php echo esc_attr( $col ) ?> masonry-item">
<ul class="pagination">
<?php echo $pagination; ?>
</ul>
</div>
<?php endif; ?>
function.php
function couponxl_format_pagination( $page_links ){
global $couponxl_slugs;
$list = '';
if (!empty($page_links)) {
foreach ($page_links as $page_link) {
if (strpos($page_link, 'page-numbers current') !== false) {
$page_link = str_replace("<span class='page-numbers current'>", '<a href="javascript:;">', $page_link);
$page_link = str_replace('</span>', '</a>', $page_link);
$list .= '<li class="active">'.$page_link.'</li>';
} else {
if (get_query_var($couponxl_slugs['coupon']) && get_option('permalink_structure')) {
$page_link = preg_replace('#coupon\\/(.*?)/#i', '', $page_link, -1);
} else {
$page_link = preg_replace('#(&\\#038\\;' . $couponxl_slugs['coupon'] . '|&' . $couponxl_slugs['coupon'] . ')=(.*?)&#i', '&', $page_link);
$page_link = preg_replace('#(&\\#038\\;' . $couponxl_slugs['coupon'] . '|&' . $couponxl_slugs['coupon'] . ')=(.*?)\'#i', '\'', $page_link );
}
$list .= '<li>' . $page_link . '</li>';
}
}
}
return $list;
}
When I change page number so page changed but page active class not change is always active page number 1 and when I click again page number 1 is not working is activate and not change in deactivate. Please tell me what I do pagination not working properly and active code not working properly.
follow this link:- http://www.cuponswall.in/store/flipkart-coupons-offers
pagination not working on this page