我自定义了我的主题,并创建了一个名为“电影”的自定义帖子类型。一切都是正确的但在主页上我想要显示所有的电影但是当我使用分页时它在第一页上是可以的,它创建其他页面链接但是当我点击其他页面链接时它创建链接但它只显示白色页面,该页面上没有显示任何内容,地址正常,我已经在我的localhost上测试了主题,但它确实有效。
这是我的分页代码
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
//$args['paged'] = $paged;
$args= array('post_type' => array('post','movies'),'paged'=>$paged);
$the_query = new WP_Query( $args );
// loop for all posts ( main page )
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post(); ?>
<div class="post-wrapper">
<div class="post-inner-wrapper">
<div class="post-title">
<span class="title">
<?php the_title() ?>
</span>
</div>
<div class="post-content">
<div class="post-outer-text">
<span class="post-inner-text">
<?php echo get_the_content(''); ?>
</span>
</div>
</div>
</div>
<div class="post-image">
<?php the_post_thumbnail(); ?>
</div>
<div class="post-details">
<span class="calendar">
<i class="fa fa-calendar" aria-hidden="true"></i>
<span class="calendar_text">
<?php the_date(); ?>
</span>
</span>
<span class="author">
<i class="fa fa-user" aria-hidden="true"></i><?php the_author(); ?>
</span>
<span class="view">
<i class="fa fa-eye" aria-hidden="true"></i><?php echo get_post_view(get_the_ID()); ?>
</span>
<span class="like">
<i class="fa fa-thumbs-o-up" aria-hidden="true"></i>256
</span>
<span class="more">
<a href="<?php the_permalink()?>">ادامه مطلب</a>
</span>
</div>
</div>
<?php
}?>
<div class="pagination">
<?php global $wp_query;
echo ($wp_query->max_num_pages);
$big = 999999999; // need an unlikely integer
$page = get_query_var('paged');
$page = (!empty($page) ? $page : 1);
// query_posts( 'category_name=category&showposts=2&paged='.$page);
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
) );?>
</div>
<?php
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}