我正在使用以下代码在模板和侧边栏插件
下显示自定义帖子类型帖子<div class="side-peoptit">
<?php $i = 1; ?>
<?php $loop = new WP_Query(
array(
'post_type' => 'people',
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'wpcf-people-sort-order',
'posts_per_page' => 4,
'paged' => get_query_var('paged') ? get_query_var('paged') : 1
)
); ?>
<?php if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?>
<?php $postid = get_the_ID(); ?>
<?php $permalink = get_permalink( $postid ); ?>
<div class="sbrpeop-title"><?php echo $i; ?>. <a href="<?php echo $permalink; ?>"><?PHP the_title(); ?></a> - <?php echo esc_html( get_post_meta( $postid, 'wpcf-people-designation', true ) ); ?> </div>
<?php $i++; ?>
<?php endwhile; endif; wp_reset_query(); ?>
</div>
以下代码我在模板中用于分页,
<div class="cus-pagi">
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $loop->max_num_pages
) );
?>
</div>
如果我访问website.com/people,自定义帖子在模板和侧边栏中都显示正确。但如果我访问第二页,我, website.com/people/page/2我的侧边栏显示为空。
有谁知道我哪里出错了?