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

  • Resolved syncbox

    (@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:

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

    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

    etc

    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">
    <?php
    $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>
    <?php
    }
    ?>
    </ul>

    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

    Hi,

    with category icons plugin, just use :
    get_cat_icon(‘cat=’.$cat->cat_ID);

    http://www.category-icons.com

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.