How to display category and tag descriptions in WordPress

Recently we talked about the importance of category pages in our blogs and websites, and how we should start optimizing them to turn them into good satellites that organize the internal diagram of a web (a good user experience and navigation of our site), and also capture some extra visitors increasing the positioning and SEO of that category or tag page (taxonomies for the purists.)

WordPress categories and tags. Do not miss their potential

WordPress pages of categories and tags are used to filter the content and make easier the access to information, giving the user a satisfying browsing experience. Besides this, we can use the power they have as pages to position keywords.

category-descripcion-wordpress

To make this works, as well as optimizing the titles and writing post excerpts, it is of utmost importance to have a description for each category and tag.

It should be a text that describes the topics to be treated. You can see the example in the category pages of this blog: for example, Web design or WordPress. For this to work properly, your WordPress theme or template must have the function of showing these descriptions in the theme.

Adding descriptions to your categories

Not all templates and themes bring this option by default. Therefore we will explain in this tutorial the easiest way to show descriptions in your category and tag pages using the Vowels theme as an example, one of the templates of SiloCreativo, which is already optimized with this functionality (you can see the demo here and browse category pages.)

tag-category-wordpress

Warning: we are going to edit some files from a WordPress theme; it is therefore advisable to first make a backup of your website and your theme. You should also note that if you update your WordPress theme or template to a new version (because a new update has come out,) you will lose these changes. If this is your case, the ideal option is to use child themes.

1 –Identify files that show category and tag pages

WordPress uses a hierarchy of templates by default to give a range of possibilities to the developer and web designers to use them. This hierarchy usually goes in WordPress categories and tags in the following order:

– First the templates called category.php and tag.php to categories and tags will be used respectively;

– In the absence of these files, WordPress will search the archive.php template;

– Finally, if there are none of these files in our directory, WordPress will use index.php by default.

It is important to locate the file we must edit. Once you have located it, it is fantastic if your hosting allows you to edit files online. Another option is to do it through the WordPress file editor or better still downloading the file, editing it offline and uploading through your ftp (Filezilla is a good FTP manager.)

2 – Show descriptions in your template

The function that we will use to manage the category descriptions will be category_description() while for the tags will be tag_description(). In the theme we are using as example (Vowels) there are specific category and tag files. We use the category.php file.

Before showing the description, we will check that there is such a text (I mean, that we have added it to our WordPress dashboard > Post> Categories.) For this, we will use the following extract that you should enter just below the title category:

<?php if (category_description() ) : ?>

Seeing that this category exists, the following code will be valid too. To do this, we will introduce in our themes the description in a div tag to give a particular style (change the font, size, background colour…)

<div><?php echo category_description(); ?></div>

Inside the div tag we will introduce the category_description() function and we will make it display. Now, we just have to close the if statement that we opened at the beginning by:

<?php endif; ?>

And it’s ready. The fact that we introduce a conditional, clean the resulting html code, without showing the div tag empty if there is no description (remember that Google indexes the html, which is on the client side, but it does not indexe the php, which is on the server side.)

We will do the same in the tag.php file, with tag_description()in this case.

3 – Recap

The resulting complete code that you can copy and paste is:

<?php if (category_description() ) : ?>
<div><?php category_description(); ?></div>
<?php endif; ?>

You should just create a few lines to style your CSS file. In Vowels, a WordPress theme by SiloCreativo, the style is:

.archive-meta {
            	font: 300 18px 'Oxygen', Helvetica, sans-serif;
            	margin: 0 auto;
            	max-width: 1040px;
            	padding: 30px 0;
            	width: 100%;
            	text-transform: none;
}

Other options: If instead your template uses the archive.php or index.php, you must always seek single_cat_title() or single_tag_title() and enter the corresponding code behind these functions.

This is as shown, for example the description of the WordPress category of SiloCreativo:

category-wordpress-descripcion

Conclusion: Improve the UX. Improve the SEO

Now we have our WordPress template with unique content for each category, which will make, with the post excerpts, each category page unique and relevant to google. (Make sure you do not have a noindex on the categories and taxonomies of your sitemap.)

But undoubtedly the gainers are your users. Properly categorize items and posts of your website help your users in navigating through the site. If you also offer an extra description of what topics are covered in each category, you will help the mental map of your users in relation to your blog or website to be clear and concise.

So you have no excuses not to optimize the category pages of your WordPress theme and improve your positioning and user experience. Do you have checked if your category pages show these descriptions?

Comments (5)

  1. I am looking for ways to activate my category and tag description by using a plugin to show it in posts but it seems that I cannot found a blog about it.

      1. Yes perhaps doing a child theme since activating it on my main template is not available. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *