我有两种自定义分类法,称为“自定义类别”和“file\\u类型”。我正在使用下面的代码列出“file\\u type”的所有术语及其相关帖子。像这样:
File\\u Type术语1
文件类型术语2
等等。。。
我的问题是,我需要添加另一个条件。我只想显示帖子,如果他们also 在“自定义类别”分类法中有一个特定的术语。因此,对于每个file\\u类型的术语,我希望它只显示具有该术语并且在自定义类别分类法中具有术语“学习单元”的帖子(术语ID为9)。
我很困惑。下面是我的工作代码,用于按file\\u类型术语列出帖子。如何添加额外条件?
<?php
$categories = get_terms(\'file_type\');
foreach ( $categories as $category ) :
?>
<h2><?php echo $category->name; ?></h2>
<?php
$posts = get_posts(array(
\'post_type\' => \'product\',
\'taxonomy\' => $category->taxonomy,
\'term\' => $category->slug
));
// Here\'s the second, nested foreach loop that cycles through the posts associated with this category
foreach($posts as $post) :
setup_postdata($post);
?>
<div class="product">
<h3><span><?php the_title(); ?></span></h3>
<?php the_post_thumbnail(\'product\'); ?>
<a href="<?php the_permalink(); ?>" class="button">Learn More</a>
</div>
<?php endforeach; ?>
<?php endforeach; ?>