Last loop not displaying on a homepage with 3 loops
-
I’m having a problem displaying 3 loops on the homepage. I need them all to post from specific categories, loop 1 and 3 will be from the same category but not duplicating posts. Loop 2 will be taken from a different category. Here’s what I’m using now but it’s not working properly:
Loop 1:
<?php $my_query = new WP_Query('category_name=portfolio&posts_per_page=2'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID; ?> <li class="slide-thumb"><img class="slider-thumb" src="<?php echo get_post_meta($post->ID, 'Thumbnail', true) ?>" width="465" height="192" alt="" /></li> <?php endwhile; ?>
Loop 2:
<?php $tempo_query = new WP_Query('category_name=blog&posts_per_page=1'); while ($tempo_query->have_posts()) : $tempo_query->the_post(); if (in_array($post->ID, $do_not_duplicate)) continue; update_post_caches($posts); ?> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <p class="tahoma-font eleven-size excerpt-text"><?php the_excerpt(); ?></p> <p class="alignright tahoma-font eleven-size moretext"><a href="<?php the_permalink(); ?>">read more</a></p> <div class="clear"></div> <?php endwhile; ?>
Loop 3:
<?php $temp_query = new WP_Query('category_name=portfolio&posts_per_page=2'); while ($temp_query->have_posts()) : $temp_query->the_post(); if (in_array($post->ID, $do_not_duplicate)) continue; ?> <div class="recent-item"> <img class="alignleft" src="<?php bloginfo('template_url'); ?>/images/mostrecent-thumb.png" width="61" height="61" alt="" /> <p class="recent-text alignright tahoma-font eleven-size"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> was created for <span>Caleb Spilchen</span>. <?php the_excerpt(); ?></p> <div class="clear"></div> </div> <?php endwhile; ?>
I know I’m probably doing some unnecessary things in my code but I’m not really a PHP coder, nor do I understand it very well, but I can usually get it to work just not this time. If someone could help me out that would be awesome, thanks!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Last loop not displaying on a homepage with 3 loops’ is closed to new replies.