paginate_links is generating same URL for all page links

I have a wordpress page to list the output of a custom table from database.
Using Pagination_link class of wordpress, I want to paginate the output but the links produced are having same links which results in redirecting yo same page.
Output is something like this:

<div class="tablenav-pages" style="margin: 1em auto"><a class="prev page-numbers" href="/hireataxi/wp-admin/admin.php?page=dc-bookings&amp;pagenum=2">«</a>
<a class="page-numbers" href="/hireataxi/wp-admin/admin.php?page=dc-bookings&amp;pagenum=2">1</a>
<span class="page-numbers current">2</span>
<a class="page-numbers" href="/hireataxi/wp-admin/admin.php?page=dc-bookings&amp;pagenum=2">3</a>
<a class="page-numbers" href="/hireataxi/wp-admin/admin.php?page=dc-bookings&amp;pagenum=2">4</a>
<a class="page-numbers" href="/hireataxi/wp-admin/admin.php?page=dc-bookings&amp;pagenum=2">5</a>
<a class="next page-numbers" href="/hireataxi/wp-admin/admin.php?page=dc-bookings&amp;pagenum=2">»</a></div> 

settings for paginate_links class is something like:

Read More
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $table_name" );
$num_of_pages = ceil( $total / $limit );
$page_links = paginate_links( array(
     'base' => add_query_arg( 'pagenum', '%#%' ),
     'format' => '',
     'prev_text' => __( '&laquo;', 'aag' ),
     'next_text' => __( '&raquo;', 'aag' ),
     'total' => $num_of_pages,
     'current' => $pagenum
) );
if ( $page_links ) {
     echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em auto">' . $page_links . '</div></div>';
}

I have searched a lot but not able to find the cause of problem.

Related posts

Leave a Reply

1 comment

  1. After some struggle I found answer myself.
    It is due to a missing parameter to be passed to paginate_links array.
    here is the argument :

    'add_args' => true,
    

    By default it is false.