2012-08-02 73 views
0

我有一个叫做“产品”的wordpress分类法。我知道我的分类模板文件将是taxonomy-product.php但是,当我使用默认的WordPress后循环时,它会显示默认的“Posts”分类的帖子,而不是我自定义的称为“product”的帖子。无法从分类中显示帖子?

我该如何解决这个问题? 这是我的代码,我已经把分类法product.php

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
<div class="product"> 
<?php the_post_thumbnail();?> 
<h2 class="product-title"> 
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a> 
</h2> 
<a class="product-view" href="<?php the_permalink() ?>">View Product</a> 
</div> 
<?php endwhile; else: ?> 
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p> 
<?php endif; ?> 

回答

0

卡莉的里面,你有问题,你是不是包括你是通过你的循环里面想环路分类。试试这个:

<?php 

$args = array('product' => 'example-product'); 
$loop = new WP_Query($args); 

while ($loop->have_posts()) : $loop->the_post(); 

<div class="product"> 

    <?php the_post_thumbnail();?> 

    <h2 class="product-title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> 

    <a class="product-view" href="<?php the_permalink() ?>">View Product</a> 

</div> 

<?php endwhile; else: ?> 

<p><?php _e('Sorry, no posts matched your criteria.'); ?></p> 

endwhile; 

?> 
相关问题