Skip to content

Instantly share code, notes, and snippets.

@quis
Created August 5, 2010 11:03
Show Gist options
  • Save quis/509562 to your computer and use it in GitHub Desktop.
Save quis/509562 to your computer and use it in GitHub Desktop.
<?
// Post category listing with support for exclusion
// $separator is a string, $excluded is an array of category slugs to be excluded from the list
// Sample call:
// echo the_category_exclude(" &middot; ", array("hidden", "admin"));
function get_the_category_exclude($separator, $excluded = array("")) {
foreach (
get_the_category()
as
$category
) {
if (!in_array($category->cat_name, $excluded)) {
$output[] = "<a href=\"" . get_category_link($category->term_id) . "\" title=\”View all posts in " . $category->name . "\”>" . $category->name . "</a>";
}
}
return implode($separator, $output);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment