
It’s been a month since I open the section “Coding Support” and glad that I am receiving a lot of queries directly to my inbox using this form. And the most popular question is about their ‘Category Templates’. Here are the sample queries.
Questions via nazcarpine.com/#coding-support:
I have this category.php file in my Wordpress theme, when they click certain category, the list of post under this category will be listed but the category title does not show up. How will I add the category title in my Category template?
Here’s a quick solution for your query:
<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
This is the start of the post loop.
Category: <?php single_cat_title(); ?>
You can also tweak the style of this line by adding heading tags between the given code: <h1>, <h2>, <h3>, <h4>, <strong>, <div> and so on
Sample Output:
<h1>Category: <?php single_cat_title(); ?></h1>
How to add Category Name and its description in my Wordpress category template when my visitors are viewing the post under Category mode?
If you want the Category description to be displayed, here’s the piece of code you will need.
<?php echo category_description(); ?>
You can paste this code below the title as discussed above.
<h1>Category: <?php single_cat_title(); ?></h1>
<?php echo category_description(); ?>
This code will display the Category name and the category description.
