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  } ?>
Share

5 Responses to ' How to display the category description in WordPress '

Subscribe to comments with RSS or TrackBack to ' How to display the category description in WordPress '.

  1. Conseils SEO said,

    on March 23rd, 2009 at 5:21 am

    Exactly what I needed for my blog, particulary useful for SEO purpose
    Thanks

  2. Morgan said,

    on January 21st, 2011 at 7:42 am

    Works perfectly – just what i needed. Love the web :-)

  3. omen said,

    on June 27th, 2011 at 11:52 am

    good job brother…i've copied your code,then i'll try …thanks you .

  4. Tamas said,

    on November 3rd, 2011 at 5:35 pm

    Thank you Justin!

  5. Crushers said,

    on January 3rd, 2012 at 7:25 pm

    This is waht I'm searching for, good work!

Leave a reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word