【发布时间】:2021-10-04 14:38:26
【问题描述】:
(首先我是 php 新手) 我有一个 wordpress 博客,在那里我写了一些关于 ppl 的文章,我将他们的名字添加为服装分类中的标签,以避免使用 polylang 的多语言字段。 我正在寻找一个允许为每个标签显示标签存在的帖子标题的循环。 示例 => 帖子名称:“厨师能做什么?” (标记为 Alex P.) 结果:-Alex P. “厨师能做什么?” 2020 年 5 月 10 日 - “世界番茄” 2020 年 12 月 15 日。 我必须为每个人(标签)制作一个手风琴。
我已经开始编写代码,但我不是在寻找解决方案,我迷路了。
<?php $tag_args = array(
'orderby' => 'title',
'order' => 'ASC'
);
?>
<ul id="Genre-List">
<li>DEFAULT</li>
<?php
$terms = get_terms(
array(
'taxonomy' => 'chef',
'hide_empty' => false,
)
);
// Check if any term exists
if ( ! empty( $terms ) && is_array( $terms ) ) {
// Run a loop and print them all
print_r($terms);
foreach ( $terms as $term ) {
?>
<li><a href="<?php echo esc_url( get_term_link( $term ) ) ?>">
<?php echo $term->name; ?>
</a></li>
<?php
}
}
?>
感谢有人能帮忙解决这个问题。我真的很生气。
【问题讨论】:
标签: php wordpress post tags taxonomy