更新时间:2023-01-29 22:53:34
$myterms = get_terms('taxonomy-name', 'orderby=none&hide_empty');
echo $myterms[0]->name;
这样你就可以发布第一项,然后你就可以创建一个 foreach
;循环:
With that you'd post the first item, yo can then create a foreach
; loop:
foreach ($myterms as $term) { ?>
<li><a href="<?php echo $term->slug; ?>"><?php echo $term->name; ?></a></li> <?php
} ?>
这样你就可以列出它们,如果你想发布所有它们,-我的解决方案-在 foreach 中创建一个普通的 wordpress 循环,但它必须有类似的东西:
That way you'd list them, if you want to post all of them, -my solution- create a normal wordpress loop inside the foreach one, but it has to have something like:
foreach ($myterms as $term) :
$args = array(
'tax_query' => array(
array(
$term->slug
)
)
);
// assigning variables to the loop
global $wp_query;
$wp_query = new WP_Query($args);
// starting loop
while ($wp_query->have_posts()) : $wp_query->the_post();
the_title();
blabla....
endwhile;
endforeach;
我发布了一些非常相似的内容 这里.
I posted something very similar here.