I'm trying to loop through all posts within a specific taxonomy, regardless of what term they're in (ie, through all terms in that taxonomy).
I have this code:
<?php
$terms = get_terms('business-books');
$booksA开发者_开发百科rgs = 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] ?>&w=110&h=155&zc=1" alt="<? get_the_title() ?>" /></a>
<h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>
<?php endwhile; ?>
I need $terms
to return an array of all the terms in 'business-books'.
Can someone aid me with this array?
Thank you!
Problem was that
$terms = get_terms('business-books');
needs to be
$terms = get_terms('business-books', 'fields=names');
精彩评论