【发布时间】:2014-07-27 22:15:32
【问题描述】:
我正在尝试在自定义模板中对我的自定义帖子类型进行分页。我是这样尝试的:
<?php
// The Query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$the_query = new WP_Query( array( 'post_type' => 'portfolio', 'portfolio_category' => 'projektowanie', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page'=>3, 'paged'=>$paged ) );
$i = 1;
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id ( $the_query->ID ), 'thumbnail' );
?>
<a href="#" data-toggle="modal" data-target="#pro<?php echo $i;?>" class="col-md-4 item-portfolio">
<img src="<?php echo $thumbnail[0]; ?>" alt="">
<h4><?php the_title(); ?></h4>
<p><?php echo get_post_meta( $post->ID, 'subtitle', true ); ?></p>
</a>
<?php if($i % 3 == 0){ ?>
<div class="clearfix"></div>
<div style="margin-top: 0px; "class="shadow"></div>
<?php } $i++; endwhile; ?>
<nav>
<ul>
<li><?php previous_posts_link( '« PREV', $the_query->max_num_pages) ?></li>
<li><?php next_posts_link( 'NEXT »', $the_query->max_num_pages) ?></li>
</ul>
当我单击下一步时,它转到 /portfolio/page/2/ 但它加载 index.php 而不是portfolio.php 文件,并且不显示来自自定义帖子类型的下一个项目。我哪里做错了?
【问题讨论】:
标签: php wordpress pagination custom-post-type