Forums

show only child category, not parent (1 post)

  1. noyz319
    Member
    Posted 5 years ago #

    Hi guys, i'm trying to get my sidebar to display the latest 3 posts in each of a few select parent categories. Along with the newest 3 posts i would like the corresponding child category of each of these posts to display as well.

    To make that clearer, what i want is this:

    FEATURES
    - MUSIC > New Classics
    - ART > The Originals
    - PEOPLE > Mikhail Gorbachev

    What i don't want is:

    FEATURES
    - FEATURES > MUSIC > New Classics
    - FEATURES > ART > The Originals
    - FEATURES > PEOPLE > Mikhail Gorbachev

    This is the code i have so far. I've also tried
    echo single_cat_title(); but that only gets me another thing i don't want,this:

    FEATURES
    - FEATURES > New Classics
    - FEATURES > The Originals
    - FEATURES > Mikhail Gorbachev


    <?php if (have_posts()) : ?>
    <div class="smaller">
    <?php
    // Sorted by Date
    {
    $posts = query_posts('category_name=features&order=desc&posts_per_page=3');
    }
    ?>
    <div class="title"><a href="http://formatmag.com/features"><strong> Features</strong><?php get_cat_icon('cat=2'); ?></a></div>
    <ul>
    <?php while (have_posts()) : the_post(); ?>
    <li>
    <div id="post-<?php the_ID(); ?>">
    <?php the_category(' > ') ?> > <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    </div>
    </li>
    <?php endwhile; ?>
    </ul>
    </div>
    <?php rewind_posts(); ?>

    I'm hoping there's an easy way to make the_category only show the children of parent cat. Any ideas? I've been stumped on this all week.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.