我正在尝试至少列出最后三个更新的自定义帖子类型的标题,让我们在另一个循环中将其称为“演员”,该循环基于名为“女演员”的分类术语列出我使用以下循环来获取我的税务条款列表:
$taxonomy = 'actress';
$term_args=array(
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC'
);
$tax_terms = get_terms($taxonomy,$term_args);
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) {
echo '<li>' . $tax_term->name.'</li>';
}
?>
</ul>
<?php
好吧,这帮助我列出了条款,但我真的很困惑如何添加与自定义帖子相关的每个条款的列表?为了更清楚,我说明了下图,希望这能让你知道我在寻找什么?你能帮我弄清楚怎么做吗?谢谢
更新
<?php
get_header();
$taxonomy = 'actress';
$term_args=array(
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC'
);
$tax_terms = get_terms($taxonomy,$term_args);
?>
<ul>
<?php
foreach ($tax_terms as $term) :
$args = array(
'tax_query' => array(
array(
$term->slug
)
)
);
// Now put the vars in the loop
global $wp_query;
$wp_query = new WP_Query($args);
// starting loop
while ($wp_query->have_posts()) : $wp_query->the_post();
the_title();
// do your thingie
foreach ($tax_terms as $tax_term) {
echo '<li>' . $tax_term->name.'</li>';
}
endwhile;
endforeach;
?>
</ul>
<?php get_footer(); ?>