事实上我发现这个代码很有效。
<?php
//edit below for categories you want excluded
$exclude = array("Latest News", "Uncategorized");
//how do you want the list separated? just a space is okay
$separator = " | ";
//don\'t edit below here!
$new_the_category = \'\';
foreach((get_the_category()) as $category) {
if (!in_array($category->cat_name, $exclude)) {
$new_the_category .= \'<a href="\'.get_bloginfo(url).\'/\'.get_option(\'category_base\').\'/\'.$category->slug.\'">\'.$category->name.\'</a>\'.$separator;
}
}
echo substr($new_the_category, 0, strrpos($new_the_category, $separator));
?>