Title: Optimize Multiple Loops
Last modified: August 20, 2016

---

# Optimize Multiple Loops

 *  [anthor](https://wordpress.org/support/users/anthor/)
 * (@anthor)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/optimize-multiple-loops/)
 * Hi there,
 * I’m trying to optimize my blog homepage. it current has 9 loops on the front 
   page. Each loop fetches 3 posts from a different category while one of them has
   an offset of 3 posts.
 * This is what each loop looks like:
 *     ```
       <h2>Category 1</h2>
                         <?php
                          $myPosts = new WP_Query();
                          $myPosts->query('cat=1&showposts=3');
                          while ($myPosts->have_posts()) : $myPosts->the_post(); ?>
                           <h3><a href="<?php the_permalink(); ?>" target="<?php echo "$pref"; ?>"><?php the_title(); ?></a></h3>
                           <div class="post-meta"><?php the_time('l, jS F, Y'); ?> - <?php the_time() ?></div>
                          <?php the_content(); ?>
       					<div class="comments-source">
                          	<div class="csleft"><a href="<?php the_permalink(); ?>"><?php comments_number( 'Leave a Comment', '1 comment', '% comments' ); ?></a></div>
                           <div class="csright">Source: <?php the_author_posts_link(); ?></div>
                          </div>
                          <?php wp_reset_postdata ?>
                          <?php endwhile; ?>
       ```
   
 * I’m using W3 Total Cache but my homepage changes every few minutes and takes 
   about 30 seconds to rebuild. Is there a more efficient way of doing this?
 * Thanks in advance.
    Anthor

The topic ‘Optimize Multiple Loops’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [anthor](https://wordpress.org/support/users/anthor/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/optimize-multiple-loops/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
