Multiple Loops on single.php – no posts returned
-
Hi all,
I’m trying to implement a second loop in one of my single.php pages (for a set category, in this case ‘images’, id 9). Nothing is being returned, though when I fiddle with the second query to change the parameters, I get strange results
Here’s my first loop:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <p> <?php the_content(); ?></p> <?php endwhile; endif; ?>
and the second:
<?php while(have_posts()) : the_post(); ?> <?php foreach((get_the_category()) as $category) { $my_query = new WP_Query('category_name=images' . $category->category_nicename . '&orderby=title&order=desc&showposts=5');} ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_excerpt(); ?> </a> <?php endwhile; ?> <?php break; endwhile; ?>
If I leave category_name blank, I get all posts from all categories – this makes me think I must be close (after HOURS!) so any help greatly appreciated!
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Multiple Loops on single.php – no posts returned’ is closed to new replies.