IM使用WordPress的一个帖子询问,但分页不工作, 我不知道什么问题,但这里是我的代码,我想这是正确的,它没有问题WordPress的静态页面分页
它显示有页面,但当我点击下一页时,它刷新页面,并且不显示任何新的结果,只是在同一页面上。
林静态页面上使用它是我的主题
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_query = query_posts(array(
'post_type' => 'cover', // You can add a custom post type if you like
'paged' => $paged,
'posts_per_page' => 1
));
?>
<?php if (have_posts()) : ?>
<?php
while (have_posts()) : the_post();
?>
<?php endwhile; ?>
///Pagination Function in Functions.php
<?php my_pagination(); ?>
<?php else: ?>
No Results
<?php endif; ?>
分页功能
if (! function_exists('my_pagination')) :
function my_pagination() {
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages
));
}
endif;