我在wordpress中使用了一个post查询,但分页不起作用,我不知道问题出在哪里,但这是我的代码,我想它是正确的,没有问题
它显示有多个页面,但当我单击下一页时,它会刷新页面,并且不会显示任何新结果,只显示同一页。
我在静态页面上使用它作为我主题的主页
<?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; ?>
Pagination Function
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;