Support » Fixing WordPress » How to display category desc in list of sub cats

  • Resolved syncbox


    I understand how to create a list of sub-categories and get each cat’s description used for the title attribute of the link…

    what I’d like to do is use the same category description in a span after the name of the category is written… basically, if I use this:

    <?php wp_list_categories('title_li=&orderby=name&use_desc_for_title=1&child_of=8'); ?>

    I get something like:

    category A
    category B
    category C

    where each is a bulleted list item. OK… and hovering over each displays a tooltip with the text from the cat desc (too bad you cannot have line breaks in these any more!)

    What I want is this:

    category A
    blah, blah, blah for cat A
    category B
    blah, blah, blah for cat B


    There’s no way to interject an echo for each list item using the template tag wp_list_categories();

    Ideas, anyone? Much appreciated!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • thanks to MichaelH for a starting bit of code, I am using this:

    <ul id="catlist">
    $categories = get_categories("title_li=&orderby=name&hide_empty=0&child_of=54");
    foreach ((array) $categories as $cat) {
    $cat_link = '<a href="' . get_category_link($cat->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $cat->cat_name) . '" ' . $rel . '>' . $cat->cat_name.'</a>';
    <li><?php echo $cat_link . '' . $cat->category_description; ?></li>

    to solve my needs. It works and because I have disabled the html stripping of category descriptions, I can style the paragraphs of the description as needed.

    I love WP. I love this forum!

    anyway to add the post count to this ?

    Just to expand on this post.. Essentially this does everything I want however I want this result from a category template…

    I need the category template to list by default the title, description (and category image using the ‘Category icons’ Plugin) of each sub category of the parent category.

    the code above you have to specify a Cat_ID.. how would I have it do this?

    any help is appreciated


    with category icons plugin, just use :

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display category desc in list of sub cats’ is closed to new replies.