Support » Themes and Templates » Custom category page listing subcat titles descriptions – how to?

  • Hello all,

    First time poster, first WP blog – excited!

    Anywho, I’m trying to set up a custom category page that will list:

    Main category title and description
    Subcategories titles (linked to subcat pages) and descriptions

    I’ve had decent luck cobbling together code found on these here forums, there’s just one tiny problem I’m having I can’t seem to solve – in the subcats, there is no line break between the subcat title and subcat description, so it all just kinda runs together.

    Here is the code I’m using:

    <div id="cattoc">
    <?php if ( is_category() ) : ?>
    <h1>Gnostic Myth + Magic</h1>
    <?php add_filter('category_description', 'wpautop'); ?>
    <?php add_filter('category_description', 'wptexturize'); ?>
    <div id="category-description">
    <?php echo category_description(); ?>
    <?php endif; ?></div>
    <ul id="catlist">
    $categories = get_categories("title_li=&orderby=name&style=none&show_count=1&child_of=82");
    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>

    Here’s the page:

    Is this a CSS issue or a PHP/MySQl issue? ANy help would be much appreciated.

    P.S. FWIW I’m also trying to figur eout how to shoehorn the code from the “category-icon” plugin in here somewhere too:

    <?php if (function_exists('get_cat_icon')) get_cat_icon(); ?>

    So that each subcat can also display a small image before the title, but that’s sometghing I haven’t attempted yet, so if I can kill two birds with one stone here, great, otherwise just one bird would be fine too 🙂



Viewing 5 replies - 1 through 5 (of 5 total)
  • This is very cool one. I’m looking for some plugin to do the this task. I aslo am looking for a category solution to include a short description for link title, and a long description for displayed top of the category archive.

    @rev max: Try putting a <br> in betwen the straight quotes, so the line reads as follows:

    <li><?php echo $cat_link . '<br>' . $cat->category_description; ?></li>

    I’m trying to do the same. For the moment, I managed everything except the category icon part.
    Any help ?

    Hi. (Hi Ness)

    To display a category icon, you must have the plugin first : Category Icons Plugin.

    Then, in your code :
    echo get_cat_icon(‘echo=0&cat=’.$cat->cat_ID);

    Thanks, Submarine ! Works perfectly 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom category page listing subcat titles descriptions – how to?’ is closed to new replies.