【发布时间】:2014-10-16 11:26:09
【问题描述】:
我已经制作了这个脚本,
<?php
function top_tags() {
$tags = get_tags();
if (empty($tags))
return;
$counts = $tag_links = array();
foreach ( (array) $tags as $tag ) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link( $tag->term_id );
}
asort($counts);
$counts = array_reverse( $counts, true );
$i = 0;
foreach ( $counts as $tag => $count ) {
$i++;
$tag_link = clean_url($tag_links[$tag]);
$tag = str_replace(' ', ' ', wp_specialchars( $tag ));
if($i < 11){
print "<li><a href=\"$tag_link\">$tag ($count) </a></li>";
}
}
}
?>
但我似乎无法获得每个标签的 tag_description。如果我在 foreach 函数中使用$description = tag_description();,它不会显示任何内容。
【问题讨论】:
标签: php wordpress foreach tags