Add category description if it exists

Find out how to add the category description to your category template in Wordpress.

Add the category description to your category templates, but only if it exists. This also wraps the description in div tags.

<?php
$category_description = category_description();
if ( ! empty( $category_description ) )
echo apply_filters( 'category_archive_meta', '<div class="description">' . $category_description . '</div>' );
?>

2 replies on “Add category description if it exists

  1. Thanks, this was just what I needed

  2. Avatar photo Jimmy Hughes says:

    Lovely stuff, thank you 🙂

Leave a Reply

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