Loop help with nested categories
-
Quick Q.. (i hope)..
I’ve got several nested categories from which i am including several (but not all) child categories as a “What’s New” section of my site. I’m trying to have it write a <p> tag prior to each loop, based on the child category.
Here’s what i’ve been trying to do:
<?php query_posts /* enter # of posts here----> */('showposts=3&cat=15,27,28,29');/* For a full list of possible arguments you can pass to query_posts see http://codex.ww.wp.xz.cn/Template_Tags/query_posts */ global $more; // Declare global $more (before the loop). $more = 0; // Set (inside the loop) to display content above the more tag. ?> <ul> <?php while ( have_posts() ) : the_post(); ?> <li> <?php if (is_category('15')) { ?> <p class="category_leadin">Article Review:</p> <?php } elseif (is_category('27')) { ?> <p class="category_leadin">Book Review:</p> <?php } elseif (is_category('28')) { ?> <p class="category_leadin">Video Review:</p> <?php } elseif (is_category('29')) { ?> <p class="category_leadin">Website Review:</p> <?php } else { ?> <?php } ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br /> <?php the_content('Read more...'); ?> </li> <?php endwhile; ?> </ul>This is how it should ideally output:
Category name
Title/link
Content
Read more…[repeat loop]
Problem is, its only returning the parent category (in this case “Reviews”), and not the child category )ex: “book reviews,” or “Site reviews.”
Does this make sense? Can anyone help me sort this out?
Thanks in advance for any insight you can offer.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Loop help with nested categories’ is closed to new replies.