在wordpress the_category()函数生成的分类列表里移除指定分类名链接

来源:互联网 发布:cs算法原理 编辑:程序博客网 时间:2024/04/30 03:24
将以下代码加入function.phpfunction the_category_filter($thelist,$separator=' ') { if(!defined('WP_ADMIN')) { //要移除的分类ID,这里是1和5 $exclude = array(1,5); $exclude2 = array(); foreach($exclude as $c) { $exclude2[] = get_cat_name($c); } $cats = explode($separator,$thelist); $newlist = array(); foreach($cats as $cat) { $catname = trim(strip_tags($cat)); if(!in_array($catname,$exclude2)) $newlist[] = $cat; } return implode($separator,$newlist); } else { return $thelist; }}add_filter('the_category','the_category_filter', 10, 2);
原创粉丝点击