In the list of posts (on a portfolio page) I want to list the other categories that post belongs to, but exclude the current category. Tried this code:
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' - '; } ?> //shows each category name with a dash afterwards
The cat_name is <?php {echo $category->cat_name . '';} ?> //only ever shows the highest alpha category
<?php if (($category->cat_name) != $et_page_title) //this variable contains current page category as its title
echo '<a href="http://www.domain.com/'.$category->cat_name.'">'.$category->cat_name.'</a>';
else echo "Same name as Title"; ?>
So, what happens is, the category that gets populated is the highest alpha category. If that's the same as the current title, I get "Same name as Title."
Is there a better way to show a list of categories, excluding the current category? There must be!