Skip to content

Instantly share code, notes, and snippets.

@coreyweb
Created March 25, 2012 14:07
Show Gist options
  • Save coreyweb/2195035 to your computer and use it in GitHub Desktop.
Save coreyweb/2195035 to your computer and use it in GitHub Desktop.
WordPress: Exclude category name from displaying on site
<?php
// place this in your theme's function.php file
function the_category_filter($thelist,$separator=' ') {
if(!defined('WP_ADMIN')) {
//list the category names to exclude
$exclude = array('Some Category','Another Category','Blah Blah Blah');
$cats = explode($separator,$thelist);
$newlist = array();
foreach($cats as $cat) {
$catname = trim(strip_tags($cat));
if(!in_array($catname,$exclude))
$newlist[] = $cat;
}
return implode($separator,$newlist);
} else {
return $thelist;
}
add_filter('the_category','the_category_filter',10,2);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment