嗨,我正在尝试使用 wordpress 遍历标签列表。标签列表是通过另一个插件生成的。
目前这是我的代码
<?php foreach($entities as $entity): ?>
<?php $str = str_replace(' ', '-', esc_attr($entity->galdesc)) ?>
<li><a href="#" id="<?php echo $str ?>"><?php echo_safe_html(nl2br($entity->galdesc)); ?></a></li>
<?php endforeach ?>
这将输出标签列表,如下所示
tag1
tag1
tag2
tag1
tag3
所有标签都会这样,但我正在尝试删除重复项,我已经研究过使用 array_unique 但无法使其正常工作。
谢谢