A friend asked if there was a way for WordPress to display the categories under which an entry is filed in the following way:
Single category: Category1
Two categories: Category1 and Category 2
Three categories: Category1, Category2 and Category3
Four categories: Category 1, Category 2, Category 3 and Category 4
And so forth.
The existing the_category()
function has no way of telling how many categories there are, and so can’t do something fancy like inserting the word “and” between the penultimate (second-to-last) and ultimate categories. So I just made a plugin with a new function called the_nice_category()
.
Download
WordPress Nice Categories Plugin (WP 1.5.1 and above)