Created
August 23, 2015 14:40
-
-
Save idavinder/21635713a04dbaf3414d to your computer and use it in GitHub Desktop.
Remove Categories from Post Meta in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Remove categories from post meta - shared on basicwp.com | |
function the_category_filter($thelist,$separator=' ') { | |
if(!defined('WP_ADMIN')) { | |
//list the category names to exclude | |
$exclude = array('Featured', 'Category #1'); | |
$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