2012-08-02 68 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; 

?> 
相關問題