我有问题。我无法在wordpress模板页面上创建分页。我在文件中创建了一个分页,现在当我在页面上创建一个不起作用的模板时,是否有人经历过这个?我正在创建一个"自定义分页"它带来了一切,但不起作用链接。
将显示分页:
<?php $paginate_links = $leitura_controller->custom_pagination($leituras->max_num_pages,"");
if ($paginate_links) : ?>
<nav class='custom-pagination'>
<?php echo $paginate_links; ?>
</nav>
<?php endif; ?>
控制器功能:
public function custom_pagination($numpages = '', $pagerange = '') {
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
if (empty($pagerange)) {
$pagerange = 2;
}
global $paged;
if (empty($paged)) {
$paged = 1;
}
if ($numpages == '') {
global $wp_query;
$numpages = $wp_query->max_num_pages;
if(!$numpages) {
$numpages = 1;
}
}
return $paginate_links = $this->leitura_model->custom_pagination($numpages, $pagerange, $paged);
}
模型功能:
public function custom_pagination($numpages, $pagerange, $paged) {
$pagination_args = array(
'base' => @add_query_arg( 'paged', '%#%' ),
'format' => 'page/%#%',
'total' => $numpages,
'current' => $paged,
'show_all' => False,
'end_size' => 1,
'mid_size' => $pagerange,
'prev_next' => True,
'prev_text' => __('«'),
'next_text' => __('»'),
'type' => 'plain',
'add_args' => false,
'add_fragment' => ''
);
return paginate_links($pagination_args);
}
我做错了什么?