将以下代码加入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);
在wordpress the_category()函数生成的分类列表里移除指定分类名链接
最新推荐文章于 2026-01-23 16:28:51 发布
本文介绍了一种改进WordPress文章分类显示的方法,通过自定义函数实现了对特定分类ID的筛选,有效提升了用户体验。
275

被折叠的 条评论
为什么被折叠?



