How to Display Category Descriptions in WordPress

Do you want to display category descriptions on your WordPress site? Categories allow you to easily sort content on your website. They also help users easily find content and are good for SEO. In this article, we will show you how to easily display category descriptions in WordPress.

Adding Category Descriptions in WordPress

WordPress comes with two built-in taxonomies called categories and tags. These taxonomies allow you to easily sort your content into different topics.

When used correctly, categories and tags can also be very helpful in improving your WordPress SEO.

WordPress allows you to add descriptions for your categories. Also in woocommerce there is a description for product categories too. However, many users don’t notice it because they create categories when writing a post which doesn’t let them add description.

In this post, we want to show you, how to add a description to a category

Head over to Posts » Categories page. If you are creating a new category, then you can simply enter category name and description here and then click on ‘Add new category’ button.

If you want to add description to an existing category, then you need to click on the ‘Edit’ link below that category.

This will take you to category edit screen where you can add description for your category.

Don’t forget to click on the ‘Update’ button to save your changes.

Repeat the process to add descriptions to all your categories. You can use the same method to add descriptions for tags as well.

Display Category Description on Category Archive Page

Most WordPress themes will automatically display the category description on the category archive pages.

However if your theme does not display category description on archive pages, then you will need to edit your theme files.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder.

Now you will need to locate and edit category.php file. If your theme doesn’t have category.php file, then you will need to edit archive.php file.

Copy and paste this code where you would like the category description to be displayed.

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

You can now save your changes and upload the file back to your website.

After that, you can visit the category archive page on your website to see the description in action.

Display Category Description in WordPress Theme

If you want to display the category description in other parts of your website, then you can also use the category_description template tag:

<?php echo category_description(3); ?>

Don’t forget to replace 3 with your own category ID.

If you want to display category description inside a single post, then you can use this code.

$catID = get_the_category();
echo category_description( $catID[0] );

This code simply gets all categories for the current post and then outputs the category description of the first category, if you wanna second category, you should change 0 on 1.

If you would like to list all your WordPress categories with a description in list format, then you can add this code in your theme’s functions.php file:

function br_catlist_desc() {
  $string = '<ul>';
  $catlist = get_terms( 'category' );
  if ( ! empty( $catlist ) ) {
    foreach ( $catlist as $key => $item ) {
      $string .= '<li>'. $item->name . '<br />';
      $string .= '<em>'. $item->description . '</em> </li>';
    }
  }
  $string .= '</ul>';

  return $string;
}
add_shortcode('br_categories', 'br_catlist_desc');

This code creates a shortcode which displays all your categories and their descriptions in a plain list.

You can now use [br_categories] in your posts and pages. To use this shortcode inside a text widget, you will need to enable shortcodes for widgets.

In Conclusion

We hope this article helped you learn how to add and display category descriptions in WordPress.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!