2011-06-27 6 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');

にする必要があるということでした
関連する問題