October 29th, 2006

How to display the category description in WordPress

When creating categories in WordPress, you can enter a description. The description field is plain text, but you can enter HTML. However, by default, WordPress doesn't even display the description when you're browsing the category!

This little bit of PHP code will override that. If your template has only one index.php that handles all page request, edit that. Otherwise, if there's an archive.php, edit that instead.

<?php if (is_category()) { ?>
      <h2 class="pagetitle">'<?php echo single_cat_title(); ?>' Category</h2>
      <div id="category-description"> <?php echo category_description(); ?> </div>
<?php  } ?>

Leave a reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image