October 5, 2021

Custom Pagination in WordPress

For custom pagination Add Following code in your current themes functions.php file.

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’ => ‘array’,
‘add_args’ => false,
‘add_fragment’ => ”

$paginate_links = paginate_links($pagination_args);

if (is_array($paginate_links)) {
echo “

echo ‘

    foreach ( $paginate_links as $page ) {
    echo “

  • $page
  • “;
    echo ‘

echo “


//call your pagination function in your post loop

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args = array(
‘paged’ => $paged, // pass paged parameter
‘post_type’=> ‘post’,
‘orderby’ => ‘ID’,
‘post_status’ => ‘publish’,
‘order’ => ‘DESC’,
‘posts_per_page’ => 4
$result = new WP_Query( $args );
if ( $result-> have_posts() ) :
while ( $result->have_posts() ) : $result->the_post();
wc_custom_pagination($result->max_num_pages,””, $paged); // call pagination function after post loop


Related Post

How to Hide Related Videos in YouTube Embeds

When an embedded YouTube video is done playing, the YouTube player normally shows several related videos, also known as “suggested videos” or “more videos”. However, there are reasons a website owner might want to hide these – due to branding preferences or simply wanting a cleaner user experience. Disable related videos on YouTube embeds by […]

Create Custom Template for Child Categories in WordPress

Create different template only for child category put following code in your current themes functions.php file

Redirect to Checkout after add to cart WooCommerce

Redirecting the user to the checkout page when they’ve added a product to their cart. This may come in handy if you only sell one product / one product per time. The filter woocommerce_add_to_cart_redirect makes it easy to redirect user to custom page. Code goes in function.php file of your active child theme (or active […]

WordPress Login Form Without Plugin

Are you need simple login form without plugin for your WordPress website? Yes, Then i have created [wc_login_form] shortcode with quick simple code. So you can put login form anywhere like in Pages, Posts and Widget etc… Therefore you just need to put [wc_login_form] shortcode where you need login form. So you need to follow […]

Disable RSS Feed in WordPress

By default WordPress generates RSS feeds for all post types, Taxonomies, Comments and etc.. that are built in, such as: http://example.com/feed/ http://example.com/feed/rss/ http://example.com/feed/rss2/ http://example.com/feed/rdf/ http://example.com/feed/atom/ There are two ways to disable RSS feed like using plugins and with custom codes. You can use many free plugins for disable RSS feeds. But let we disable RSS […]

Enable SVG Support in WordPress

For Enable svg support you’ll need to add the following code to your current themes functions.php file.

Leave a Reply

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