大家好,谢谢大家的帮助!我有一个插件,我试图为自定义查询进行分页。一切似乎都很好,但当我点击第2页(或任何不是“1”的页面)时,wordpress说
您没有足够的权限访问此页面
我认为这个错误是因为我尝试的这种分页方法的URL是:
/wp管理员/管理员。php?第页=lismovim收回段塞/第页/第2页/
所以,我想WP不会重新迁移这个地址。有什么想法吗?也许可以用其他方式分页?我真的需要一些帮助,我现在上网很长时间了,找不到任何解决办法。这是我的代码:
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.