Reputation: 85
im using
<?php
foreach((get_the_category()) as $category) {
$cats .= $category->cat_name . ', ';
}
echo rtrim($cats, ', ');
?>
to display the category names of a post. How would i go about out removing a specific category from this list
Upvotes: 0
Views: 343
Reputation: 12469
Untested but something like this should work:
<?php
foreach((get_the_category()) as $category)
{
if($category->cat_name == "category name")
{
}
else
{
$cats .= $category->cat_name . ', ';
}
}
echo rtrim($cats, ', ');
?>
Upvotes: 3