Using <?php the_category; ?> w/ more than 2 categories
-
OK, I’ll try and be descriptive:
When I put a blog post in one category, my <?php the_category; ?> tag works fine. When I put my blog post in two categories, my <?php the_category; ?> tag works fine, I just put an “and” in for the seperator, and everything still works just fine.
Now here’s my dilemma, what do I do when I have three or more categories? I want to have a comma in between every category except the last one, and then have an ampersand in the last one; i realize how to put the ampersand in for the last one, I’m just wondering if it’s possible to have a comma for all but the last category, and an ampersand for the last category.
Example:
“This post is in the weird category” <- I can do this
“This post is in the weird and awesome category” <- I can do this
“This post is in the weird, awesome & funny category” <- Can I do this?
“This post is in the weird, awesome, funny, super & amazing category” <- Can I do this?
PS Is there a tag where I can display one word when my post is in only one category and another when my post is in more than one category?
- The topic ‘Using <?php the_category; ?> w/ more than 2 categories’ is closed to new replies.