Ecommerce Shopify WordPress Discussion

How to make the previous/next pages always visible in pagination

I have a pagination function and the main class where I initialize this function. I need to make sure that the Previous button and the Next button are always visible, just so that the Previous button is disable on the first page and the Next button on the last. I followed the example from the WordPress documentation. How can I do this? function paginate_links($args = '') { global $wp_query, $wp_rewrite; //... if ($args['prev_next'] && $current && 1 < $current): $link = str_replace('%_%', 2 == $current ? '' : $args['format'], $args['base']); $link = str_replace('%#%', $current - 1, $link); if ($add_args) { $link = add_query_arg($add_args, $link); } $link .= $args['add_fragment']; $page_links[] = sprintf( '<div class="arrow" data-number="%s"> Previous < /div>', $current - 1, $args['prev_text'] ); endif; for ($n = 1; $n <= $total; $n++): if ($n == $current): $page_links[] = sprintf( '<div data-number="%s" class="page-numbers current">%s</div>', esc_attr($args['aria_current']), $args['before_page_number'].number_format_i18n($n).$args['after_page_number'] ); $dots = true; else : if ($args['show_all'] || ($n <= $end_size || ($current && $n >= $current - $mid_size && $n <= $current + $mid_size) || $n > $total - $end_size)): $link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']); $link = str_replace('%#%', $n, $link); if ($add_args) { $link = add_query_arg($add_args, $link); } $link .= $args['add_fragment']; $page_links[] = sprintf( '<div class="page-numbers" data-number="%s">%s</div>', /** This filter is documented in wp-includes/general-template.php */ $args['before_page_number'].number_format_i18n($n).$args['after_page_number'], $args['before_page_number'].number_format_i18n($n).$args['after_page_number'] ); $dots = true; elseif ($dots && !$args['show_all']): $page_links[] = '<span class="page-numbers dots">'.__('…'). '</span>'; $dots = false; endif; endif; endfor; if ($args['prev_next'] && $current && $current < $total): $link = str_replace('%_%', $args['format'], $args['base']); $link = str_replace('%#%', $current + 1, $link); if ($add_args) { $link = add_query_arg($add_args, $link); } $link .= $args['add_fragment']; $page_links[] = sprintf( '<div class="arrow" data-number="%s"> Next < /div>', /** This filter is documented in wp-includes/general-template.php */ $current + 1, $args['next_text'] ); endif; switch ($args['type']) { case 'array': return $page_links; case 'list': $r .= "<ul class='page-numbers'>\n\t<li>"; $r .= join("</li>\n\t<li>", $page_links); $r .= "</li>\n</ul>\n"; break; default: $r .= "<div class='number'>"; $r .= join("\n", $page_links); $r .= "</div>"; break; } return $r; } <div class="pagination"> <?php echo ThemeClass::paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => '/page/%#%', 'current' => $_GET['page'] ?? 1, 'total' => $news->max_num_pages, 'prev_text' => __('« prev'), 'next_text' => __('next »'), )); ?> </div>
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.