WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following code to show the subcategories of a category within my archive.php page:

<?php if (is_category()) {
  $this_category = get_category($cat);
  if (get_category_children($this_category->cat_ID) != "") {
    echo "<div id='catlist'><ul>";
    echo "</ul></div>";

The code above returns the name of the category as a link, with the category description as the link title.

Can anyone show my how to show the category description within paragraph tags after the category link?


share|improve this question
up vote 1 down vote accepted

wp_list_categories formats the results, instead you want to try get_categories and create your own loop to format the results.

I do not know exactly how you want it formated, but this gives you the general idea.

if (is_category()) {
    $this_category = get_category($cat);
    if (get_category_children($this_category->cat_ID) != "") {
        echo '<div id="catlist"><ul>';
        $childcategories = get_categories(array(
            'orderyby' => 'name',
            'hide_empty' => false,
            'child_of' => $this_category->cat_ID
        foreach($childcategories as $category) {
            echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
            echo '<p>'.$category->description.'</p>';
        echo '</ul></div>';

For more examples and information visit, get_categories

share|improve this answer
That is perfect, thank you! :) – D-B Aug 4 '11 at 15:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.