Hi everybody and tks in advance for your help! I have a plugin and I was trying to do some pagination for a custom query. Everything seems to work fine, but when I click on page 2 (or whatever not being "1"), wordpress says
You do not have sufficient permissions to access this page
I believe that this error is because with this pagination method that I was trying, the URL is:
/wp-admin/admin.php?page=lismovim-withdraw-slug/page/2/
So, I suppose that WP doesn't reconigze this address. Any ideas? Maybe some other way to do the pagination? I really need some help, I was surfing the internet quite long now and couldn't find any solution. Here's my code:
function listado_movimientos(){
echo '<p><strong>LISTADO DE MOVIMIENTOS APROBADOS/DECLINADOS<strong></p>';
echo '<table class="wp-list-table widefat fixed striped axdepositbycash">
<tr style="font-weight: bold;font-size: 15px">
<td>ID</td>
<td>FECHA</td>
<td>USUARIO</td>
<td>NOMBRE</td>
<td>CANTIDAD</td>
<td>Nº CUENTA</td>
<td>ESTADO</td>
</tr>';
$rows_per_page = 10;
$current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;
global $wpdb;
$table_name = $wpdb->prefix. "withdraw";
$result2=$wpdb->get_results("select * from $table_name where status='aprobado'");
$pagination_args = array(
'base' => @add_query_arg('paged','%#%'),
'format' => '',
'total' => ceil(sizeof($result2)/$rows_per_page),
'current' => $current,
'show_all' => false,
'type' => 'plain',
);
$pagination_args['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . 'page/%#%/', 'paged');
if( !empty($wp_query->query_vars['s']) )
$pagination_args['add_args'] = array('s'=>get_query_var('s'));
echo paginate_links($pagination_args);
$start = ($current - 1) * $rows_per_page;
$end = $start + $rows_per_page;
$end = (sizeof($result2) < $end) ? sizeof($result2) : $end;
echo '<br />';
echo '<br />';
for ($i=$start;$i < $end ;++$i ) {
$r2 = $result2[$i];
echo '<tr>
<td>'.$r2->id.'</td>
<td>'.$r2->wdate.'</td>
<td> '.$r2->fname. " " . $r2->lastname.'</td>
<td>'.$r2->name.'</td>
<td>'.$r2->amt.'</td>
<td>'.$r2->acno.'</td>
<td>'.$r2->status.'</td>
</tr>';
}
echo "</table>";
}
Here is the original snippet, where I found how to do the pagination in the first place.