当然,只需将您的标签列表提供给wp_generate_tag_cloud:
$found_tags = $final_tags = $id_records = array();
// get last 10 posts
$last_posts = get_posts(\'numberposts=10\');
// gather tags
foreach($last_posts as $post)
$found_tags = array_merge($found_tags, wp_get_post_tags($post->ID));
// prepare final tags for the cloud
foreach($found_tags as $tag){
// ignore duplicates
if(in_array($tag->term_id, $id_records))
continue;
// track ids...
$id_records[] = $tag->term_id;
// generate links
$tag->link = get_tag_link($tag);
// keep it
$final_tags[] = $tag;
}
// feed to the cloud
print wp_generate_tag_cloud($final_tags);
您可能想缓存它,因为它会进行很多查询