WordPress – How to Display Category Name and Description in Theme

wordpress-tutorial-category-description
In this WordPress tutorial we will see how to print or display category / archieve name and description in your WordPress theme.

How To Display Category Name

Use below code to print category / archieve name in your WordPress theme.

1
the_archive_title( '<h1 class="archive-title">', '</h1>' )

In above code you can change class and heading tag.

How To Display Category Description

Use below code to print category / archieve description in your WordPress theme.

1
the_archive_description( '<div class="archive-description">', '</div>' )

In above code you can change class of div.

We generally put these codes in archieve.php of a WordPress theme to display category name and description. This is full code to display both category name and description.

1
2
3
4
5
6
<header class="page-header text-center section">
  <?php
  the_archive_title( '<h1 class="category-title">', '</h1>' );
  the_archive_description( '<div class="category-description">', '</div>' );
  ?>
</header>

How to add description to a category

Navigate to:
WordPress Dashboard Posts Categories

Click Edit link of the category of which you want to add description. on next page you can add description to this category. See below image.

wordpres-category-description

Hope this article was helpful to you.

Related Posts

Leave a Reply

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