How to Display Category Descriptions in WordPress

This page may contain affiliate links from which I may make a commission at no cost to you. See How SideGains Makes Money for more information.

How to Display Category Descriptions in WordPress

I’ve had a tricky problem to resolve. My current WordPress theme does not employ the function to display category descriptions on my category pages. So I understand some things are made like this, and I am happy with mine. But the thing is I want my category pages to include a description. What follows is the result of my research on how to display category descriptions in WordPress. I’ve come across several scenarios:

  • Using category.php.
  • Using archive.php.
  • When your WordPress theme doesn’t have either of the above… like me!

Before I do so, I’ll provide a brief explanation of WordPress categories to set the scene.

What are WordPress Categories?

I’ve explained their purpose in a very detailed way in my post about WordPress categories and tags. However as a general explanation, WordPress categories provide a way to connect broadly related content together in different sections.

Most often you’ll see WordPress categories as the links in a main navigation menu or in a sidebar widget. WordPress automatically creates a page for each category you create, and these pages display all the posts assigned to them. Hence when you click a link in your navigation menu you’ll arrive at a category page with all the posts added to that category.

When you create a category page you can write a description for it that most WordPress themes will use to pull into the page and display it beneath the category title. Here’s where my issuette arises: my theme doesn’t do this.

A Note on Your WordPress Categories

In order to display WordPress category descriptions… you’ll need, erm, category descriptions!

You’ll find all of your categories under the Posts menu in your WordPress dashboard. Simply go to your dashboard click Posts > Categories and you’ll see all the ones you’re presently using.

WordPress Categories Editor

From this area you can create new categories, edit existing ones or remove any you don’t require.

How to Display WordPress Category Descriptions When Your Theme Doesn’t!

If you find your WordPress theme does not automatically display the category descriptions you’ve written for them, there are several approaches I’m going to discuss here that’ll help.

Each of them requires you to edit theme files. So you’ll need to create a WordPress child theme and / or copies of the files after you’ve modified them. The reason being, if you update your WordPress theme the files will be overwritten and your edits lost.

A child theme protects any theme files you edit. Failing that, you can use your copies to reinsert the code you need into the files that have been overwritten if you update your theme.

Always make a backup copy of ANY WordPress theme file you edit before you make any changes. If something goes wrong with code you introduce, you can always swap back to your original file.

So here goes…

Approach 1 – category.php

The first approach is to edit one of your theme files called category.php. This will reside in the WordPress theme folder on your server, so you’ll need to connect to it either via an FTP client or by using your server cPanel admin tools.

If you have a category.php file (my theme doesn’t) you’ll find it on your server here:

/wp-content/themes/your-current-theme/category.php

Make a backup copy of the category.php file (just in case). Then add the following code within the file where you’d like your WordPress category description to appear… perhaps beneath the H1 title tags for the category page:

<?php the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?>

Remember to save the file when you’ve finished editing it. Then visit your category pages to see if your category descriptions are present. If that hasn’t worked, roll back the changes to the category.php file and try the next approach.

Approach 2 – archive.php

This approach is exactly the same as editing category.php except you’re looking to edit the archive.php file. This will reside in the same WordPress theme folder on your server, so connect via an FTP client or your server cPanel admin tools.

If you have an archive.php file (my theme doesn’t) you’ll find it here:

/wp-content/themes/your-current-theme/archive.php

Backup the archive.php file and then add the same line of code where you want your category description to appear. Again, you could locate the H1 title tags and add the code directly beneath to have your category description appear beneath the page title:

<?php the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?>

Save the file after editing it and visit a category page to see if the category descriptions are now present. If that hasn’t worked, restore your archive.php file and try the next approach.

Approach 3 – Custom Functions

This approach will vary according to the WordPress theme you use. I’m presently using the MH Newsdesk theme by MH Themes. Your theme may work differently to mine.

If you don’t have category.php or archive.php files, you may have to dig around in your theme to find which file it uses to build your category page.

Since I use the MH Newsdesk theme, the file I had to update is this one:

/wp-content/themes/mh-newsdesk/includes/mh-custom-functions.php

This is the file that handles the rules around category pages for my theme. As a result it works differently than the standard category.php and archive.php WordPress pages.

Nonetheless the code is similar, though it does include an if statement to check if the page is a category page. I’ve pasted the following code in a nested if statement, beneath where the H1 tag is created for category pages:

if (is_archive()) {
    if (is_category() || is_tax()) {
    the_archive_description( '<div class="taxonomy-description">', '</div>' );
    }
}

This code checks to see whether the page required is a category page, and if so it displays the category description on the page it builds.

Please Note

I should stress, the way your theme works may be different to mine and you may not need to include the if statement as I have. It may be that you may be able to use the code in the examples for category.php and archive.php instead.

This approach requires a bit of investigative work on your part. You may find that you also have a custom page that builds your category pages in the absence of category.php or archive.php. files. If you do, you may have to do a little code unpicking to understand:

  • Which of your WordPress theme files handles the creation of category pages.
  • How the custom file indentifies category pages and subsequently how it builds them.
  • Where in your custom file you need to add the code.

As with all approaches, be sure to back up any files before you edit them as all files mentioned are crucial to WordPress running properly. If you have a problem simply restore your back up copies to their original location(s).

Summary

  • Most WordPress themes automatically populate the category pages with the descriptions you’ve made for them.
  • Some themes require intervention to display category descriptions in WordPress.
  • You may be able to edit certain files (category.php or archive.php if you have them), or edit another file in your theme (which you’ll have to identify) to display descriptions on your WordPress category pages.
  • Before you make any changes to WordPress theme files, make back ups so you can restore them if something goes wrong and breaks your site.
  • Use a WordPress child theme or backup any theme files you modify. If you don’t, say goodbye to your updates as they will get overwritten when you upgrade your theme!

That’s it for now!

Paul

Please feel free to share any of the above images on Pinterest.

I’d be interested to hear your thoughts on how to display category descriptions in WordPress. Please drop a comment below.

3 Comments on "How to Display Category Descriptions in WordPress"

  1. Oh wow so you had to do it the hard way. Thanks again for sharing this with us and saving us a lot of time! Cheers, James

  2. Hi Paul, thanks for doing the technical research for us! When you searched for this, did you start out by googling specifically for your theme or for WP in general? I always start out by googling for my theme, in your case “MH newsdesk WP theme how to add category descriptions” and if I can’t find anything there, nor any documentation, I’ll broaden the search. Just curious how you found this out! Cheers, James

    • Hey James. I know the WP function to pull WordPress category descriptions so just searched in Google around the MH Newsdesk theme to find an answer. I couldn’t find one, even in the WP theme support forum itself, though I did find questions about the same issue. Sadly no answers above “the theme doesn’t support them for display reasons”. I decided then to dig around the theme files on my server to look for for the file / code that builds category pages. When I found it, I just called the category description function into the IF statement that checks for taxonomy type.

      Unfortunately I couldn’t update the WP theme forum questions with my solution since comments are closed on them.

Leave a comment

Your email address will not be published.


*