This is something that has troubled me for the better part of the day. I created a new category.php template file for my girlfriend's cooking blog (you can see it here).
I wanted a specific layout for the category page - not the default one provided by the theme I use (Patchwork).
I googled around and eventually found that I could use the Wordpress PHP function <?php single_cat_title( $prefix, $display ); ?>
as described in the Wordpress Codex. The point was then to use the Wordpress shortcode [catlist]
. The shortcode can either take the category name or the category id.
I thought that would be it but unfortunately my girlfriend's blog is a bilingual one which means that single_cat_title
doesn't always return the same value. It might return recipe
in English and recette
in French neither of which can be used to resolve the category in [catlist]
. And if you think this is a corner case for bilingual blogs, it's not... It also applies to blogs that have categories with the same name (as to why you would have that, I don't know...)
All the other methods I could find were all specific to the_loop and not applicable in my case.
Anyway, I thought I would share the answer below for everyone's benefit. When I found it, it made my day!