WordPress.org

Ready to get started?Download WordPress

Forums

Custom category page listing subcat titles + descriptions - how to? (6 posts)

  1. rev max
    Member
    Posted 6 years ago #

    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(); ?>
    </div>
    <?php endif; ?></div>
    
    <ul id="catlist">
    <?php
    $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>
    <?php
    }
    ?>
    </ul>

    Here's the page:

    http://www.enemies.com/category/gnostic-myth-magic/

    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 :-)

    thx

    Max

  2. Binh
    Member
    Posted 6 years ago #

    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.

  3. Kalessin
    Member
    Posted 6 years ago #

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

  4. Nessdufrat
    Member
    Posted 6 years ago #

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

  5. submarine
    Member
    Posted 6 years ago #

    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);

  6. Nessdufrat
    Member
    Posted 6 years ago #

    Thanks, Submarine ! Works perfectly :)

Topic Closed

This topic has been closed to new replies.

About this Topic