我有一个自定义的帖子类型,“design\\u asset”。
我将它们显示在页面模板上,带有循环
<?php
rewind_posts();
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var(\'paged\') : 1;
$args = array( \'post_type\' => \'design_asset\', \'posts_per_page\' => 100, \'orderby\' => \'title\', \'order\' => \'ASC\' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col-md-4 col-xs-12">
<div class="thumbnail">
<div class="caption">
<?php the_post_thumbnail( \'thumbnail\', array(\'class\' => \'img-responsive\') ); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p class="excerpt"><?php the_excerpt(); ?></p>
</div>
</div>
</div>
<?php endwhile; ?>
同样在这一页上,我列出了wp_list_categories
单击此列表中的类别时,它将转到存档。php并在此处显示类别,thanks to this post\'s reply, e、 g。/category/components/
我不完全理解Wordpress为什么使用archive.php
而不是category.php
, 但现在让我们继续吧。
现在,我正在尝试重新设计这个循环archive.php
. 我把它搬到了loop-assetThumbs.php
并称之为<?php get_template_part(\'loop\', \'assetThumbs\'); ?>
当然,它会调用所有帖子或帖子类型,我不知道如何在URL中只显示“活动”类别,/category/components/
如何修改循环以执行此操作?或者有没有更好的方法通过wp_list_categories
?
注意:我也不知道为什么这里会显示循环的2个空迭代。