2011-06-27 34 views
0

我試圖循環遍歷特定分類中的所有帖子,而不管它們在哪個術語中(即通過該分類中的所有術語)。WP_Query通過分類的所有術語

我有這樣的代碼:

<?php 
    $terms = get_terms('business-books'); 
    $booksArgs = array(
    'posts_per_page' => '1', 
    'tax_query' => array(array(
      'taxonomy' => 'business-books', 
      'field' => 'slug', 
      'terms' => $terms 
    )) 
    ); $books = new WP_Query($booksArgs); while ($books->have_posts()) : $books->the_post(); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), full); ?> 
    <a href="<?php the_permalink(); ?>"><img src="<? echo get_bloginfo('template_directory'); ?>/timthumb.php?src=<? echo $thumbnail[0] ?>&amp;w=110&amp;h=155&amp;zc=1" alt="<? get_the_title() ?>" /></a> 
    <h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>    
<?php endwhile; ?> 

我需要$terms在「商業圖書」返回所有條款的數組。

有人可以幫助我這個數組?

謝謝!

回答

3

問題是

$terms = get_terms('business-books');

需要是

$terms = get_terms('business-books', 'fields=names');

相關問題