【发布时间】:2018-12-09 17:07:30
【问题描述】:
我正在尝试在 WordPress 中为 woocommerce 主题创建一个循环,以按字母顺序列出所有产品标签 以一种简单的方式“在其下方以 A 为标题,所有标签都以 A 字母等开头”。 我正在使用代码,但它返回 null
<?php
$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag-
>slug}'>";
$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;
?>
【问题讨论】:
标签: php wordpress sorting woocommerce custom-taxonomy