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.
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(); ?> <?php 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> <?php $blog = get_the_category('category_parent=2194'); $blog->cat_name; ?> <div class="blog-title">from <a href="/blogs/<?php echo $blog->category_nicename;?>"><?php echo $blog->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?
- The topic ‘show only one category from specific parent when listing posts’ is closed to new replies.