【发布时间】:2016-08-08 17:44:01
【问题描述】:
我正在尝试在 wordpress 中的自定义帖子中添加分页。我的自定义帖子类型名称是视频。它出现了分页,但是当我点击分页页面时,它会转到 404 页面。
<?php
$videos= new WP_Query(array(
'post_type'=>'videos',
'posts_per_page' => 9,
));?>
<?php if($videos->have_posts()) : ?>
<?php while($videos->have_posts()) : $videos->the_post(); ?>
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
<div class="video">
<?php the_post_thumbnail(); ?>
<div class="watch">
<a href="<?php the_permalink(); ?>"><i class="fa fa-play"></i></a>
</div>
</div>
<div class="video-exerpt">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
</div>
<?php endwhile; ?>
<div class="col-xs-12 text-center">
<?php
$GLOBALS['wp_query'] = $videos;
the_posts_pagination(
array(
'mid_size' => '2',
'prev_text' => '<i class="fa fa-hand-o-left"></i> Previous',
'next_text' => 'Next <i class="fa fa-hand-o-right"></i>',
'screen_reader_text' => ' '
)
);
?>
</div>
<?php else :?>
<h3><?php _e('404 Error: Not Found', 'Bangladesh Parjatan'); ?></h3>
<?php endif; ?>
<?php wp_reset_postdata();?>
它显示分页 bt 链接不起作用。请帮帮我。
【问题讨论】:
-
你能在这里也显示分页链接的渲染 html 吗?
-
您已经为按钮生成了文本,但您没有生成链接。看看css-tricks.com/snippets/wordpress/paginate-custom-post-types
标签: php wordpress pagination custom-post-type