Display Categories on Post with Separators
-
I am using the page of posts format narrowing down the post by the category to match the page. For any one post, there can be several categories. At the end of the each post, I want to display the categories that particular post is in.
I found:
<?php the_category(' • ') ?>That will separate the categories, but the categories are links (I don’t want them to be links)
Then I found:
<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' ';}?>Which will only display (not be a link), but it doesn’t use a separator between the categories.
If I put something in between the ‘ ‘ marks it displays after every category – even if there isn’t another category behind it (i.e. if there was only 1 category, then it still displays that separator).
I am fairly new to using this, and have been able to find answers to all of my other questions, but can someone please help me out with this?
I want to display the categories, without them being links, and them have a separator between them when appropriate.
Thank you!
The topic ‘Display Categories on Post with Separators’ is closed to new replies.