[resolved] show only one category from specific parent when listing posts (3 posts)

  1. jesseisrad
    Posted 5 years ago #


    I'm trying to use WP as sort of a multiblog by creating parent category: Blogs with sub cats of "Free Agency" and "Beltway Outsider". Simple enough, but posts can be assigned one of those child cats, but also some other ones.

    What I'd like to do is have a list of only those posts that are in that parent cat (Blogs), which I have done, but then have a call out to see the rest of that "blog" by linking to that child cat and ONLY that child cat.

    Example: http://img.skitch.com/20100408-fjp7s1jfiggeatdqcjy8b9ky95.png

    Code I'm using:

    <?php $blogs_query = new WP_Query('cat=2194&showposts=10');
    	if ($blogs_query->have_posts()) :
    	while ($blogs_query->have_posts()) : $blogs_query->the_post(); ?>
    global $more;
    $more = 0;
    <h3 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    $blog = get_the_category('category_parent=2194');
    <div class="blog-title">from <a href="/blogs/<?php echo $blog[0]->category_nicename;?>"><?php echo $blog[0]->cat_name;?></a></div>
    <div class="clear">	</div>
    <?php endwhile; endif;?>

    So the problem is that it's just pulling out the first category listed, which 90% of the time is the correct one but sometimes (as circled) it pulls in some other category.

    I need a way to list only categories from a particular parent. Any ides?

  2. jesseisrad
    Posted 5 years ago #

    So basically:

    check if the post has a child cat of said parent, then list said category.

  3. jesseisrad
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic