我做了这个剧本,如何在foreach WordPress模板中获取tag_description?
<?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();
,它不会显示任何内容。
不,仍然没有看到。尽管感谢您的回答。 – Siyah 2014-10-16 11:32:32
您上次编辑的作品。谢谢你,谢谢! – Siyah 2014-10-16 11:33:21
你有没有试过我的编辑?标签更改为“post_tag”中的get_term_by – 2014-10-16 11:33:37