Each WordPress category may be provided with a description within the administration panel. Why a description is important for a WordPress category? The main benefit derived from using a description is mainly related to search engines and SEO optimization. If you specify a semantic markup structure, you can actually improve your site by adding more context to each category. Another benefit is for users: using a category description helps your readers to understand the topic you're writing about. Let's see how to use this feature in WordPress.
The function used to display a category's description is category_description():
<?php echo category_description( $category_id ); ?>
$category_id
is the optional ID of the category you want to display the description. This function defaults to the current category when used inside category.php
.
You can also use the category's slug:
<?php echo category_description( get_category_by_slug('category-slug')->term_id ); ?>
What's more, it's the HTML structure you'll choose that makes the difference from a SEO perspective:
<h1 class="cat-title"><?php single_cat_title();?></h1> <p class="cat-desc"><?php echo category_description();?></p>
A good combination is always heading + paragraph. Just remember to put your markup structure on top.