【问题标题】:WP_Query through all terms of a taxonomyWP_Query 通过分类的所有术语
【发布时间】:2011-06-27 14:21:36
【问题描述】:

我正在尝试遍历特定分类中的所有帖子,无论它们在哪个术语中(即,通过该分类中的所有术语)。

我有这个代码:

<?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 来返回“商业书籍”中所有术语的数组。

有人可以帮我处理这个数组吗?

谢谢!

【问题讨论】:

    标签: wordpress taxonomy


    【解决方案1】:

    问题是

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

    需要

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

    【讨论】:

      猜你喜欢
      • 2018-09-27
      • 1970-01-01
      • 1970-01-01
      • 2015-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      相关资源
      最近更新 更多