If you’ve been browsing websites for a while now, you probably noticed that some of them display a category description when you are on a category archive page. This is important because it lets the visitor know, what kind of articles he or she can find in that specific category. For some reason, thou, not too many WordPress themes support this feature.
Fortunately, it’s not hard to implement. So in this tutorial, I’ll walk you through the steps of display the category description on archive pages in any WordPress theme.
Setting up the Category description
To get started, first, you’ll need to set these category descriptions.
You can do this, by going to your admin dashboard, posts -> categories.
Select the category you want to add a description for and type your description inside the textbox that says description.
Once done, click save. Now go ahead and do this to all the categories you want to set a description for.
The next step is to display the description we set in our theme. Let’s see how.
Display the Category Description in the Theme
The first step you need to do is located the “archive.php” file of your theme. This is usually located inside wp-content/themes/your-theme/
Once you found it, open it up with your favorite text editor.
Then you’ll need to add the following code snippet, below the title of the archive. This is Usually wrapped in an <h1> or <h2> tag. In the SocialyVIral theme, it’d look something like this:
<h1 class="postsby"> <span><?php the_archive_title(); ?></span> </h1>
After you found the location where you want to display the category description, simply paste the following code under it.
<div class="cat_description"><?php echo category_description( $category_id ); ?></div>
Save the file, and then you are done. Now if you check the archive page of the category page you’ve set the description for, you’ll notice that it’ll appear under the archive’s title.
And that is it. My opinion is that its such simple, yet useful feature and only a handful of themes actually display it.
Hope this helps you display the category description in WordPress Themes.
Get more stuff like this
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Thank you for subscribing.
Something went wrong.