我们可以按类别创建,并转换为自定义类别小部件。有几个插件应该能够过滤特定类别的标签。例如:TDO标记修复和敏感标记。
//获取特定类别的标记
<?php
query_posts(\'cat=1&posts_per_page=-1\');
if(have_posts()): while (have_posts()) : the_post();
$all_tag_objects = get_the_tags();
if($all_tag_objects){
foreach($all_tag_objects as $tag) {
if($tag->count > 0) {$all_tag_ids[] = $tag -> term_id;}
}
}
endwhile;endif;
$tag_ids_unique = array_unique($all_tag_ids);
//Listing tags per category
foreach($tag_ids_unique as $tag_id) {
$post_tag = get_term( $tag_id, \'post_tag\' );
echo \'<li><a href="\'.get_tag_link($tag_id).\'">\'.$post_tag->name.\' ( \'.$post_tag->count.\' )</a></li>\';
}?>
//Creating a tag cloud for a specific category
wp_tag_cloud(\'include=\' . implode(\',\', $tag_ids_unique));