Title: Index Posts duplicating indefinitely.
Last modified: August 20, 2016

---

# Index Posts duplicating indefinitely.

 *  [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/)
 * I only know very basic php and am running into problems. I’m trying to have 7
   individual divs (representing different main categories), within those divs, 
   I’m trying to populate the post titles from those categories within it. For some
   reason after the last div, it repeats continually. Can anybody help me out please?
 * The code is listed below is listed at: [http://pastebin.com/KsENfvTi](http://pastebin.com/KsENfvTi)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708199)
 * don’t use `query_posts()` within a loop;
 * try to change this section to use ‘get_posts’ as well:
 *     ```
       <?php
                                                               query_posts('category_name=gluten-free-living&showposts=-1'); while(have_posts()) : the_post();
                                                               ?>
                                                               <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
                                                               <?php endwhile; ?>
       ```
   
 * and add:
    `<?php wp_reset_postdata(); ?>` before line 93 `<?php endwhile; ?>`
 *  Thread Starter [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708209)
 * It still duplicating: This is one of the div boxes, I have 7 of these, each with
   individual categories. I placed the “wp_reset_postdata90: ?> as well
 * Code: [http://pastebin.com/ehkquwCA](http://pastebin.com/ehkquwCA)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708219)
 * please post the edited full code of the tempalte again using the pastebin [http://pastebin.com/](http://pastebin.com/)
 * I didn’t see 7 boxes in the first pastebin (?)
 *  Thread Starter [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708220)
 * I only have 4 listed in the main code. I was making sure it worked properly before
   adding the other categories. I will add the 7 and repost
 *  Thread Starter [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708224)
 * Here is the updated code with 6 categories (not seven, my apologies on the miscommunication)
 * [http://pastebin.com/k7fqzbDS](http://pastebin.com/k7fqzbDS)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708239)
 * the latest posted code does not repeat indefinitively – just as often as the 
   number of posts per page setting.
 * what page is this template used for?
    is it the index.php template?
 * because the seven blocks are within the main loop, they will be repeated for 
   as many _**posts per page **_are set in the _**settings – reading**_.
 * —-
    try to use at the start of the loop:
 *     ```
       <?php while (have_posts()) : the_post(); ?>
       	<?php $count = 0;  $temp = $posts; ?>
       ```
   
 * and at the end:
 *     ```
       <?php wp_reset_postdata();
       $posts = $temp; ?>
       <?php endwhile; ?>
       ```
   
 *  Thread Starter [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708244)
 * It is in the index page. I currently have the posts per page in the settings –
   reading area to 4.
 * I entered the information and its still repeating. I’m not sure if its an error
   elsewhere?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708245)
 * > its still repeating
 * is it repeating 4 times or more ?
 * what else do you need to show in the index page?
    there might be the need to 
   pull your 7 blocks out of the loop.
 * (also keep in mind that index.php is used as the general template if the more
   specialized templates are not in the theme – see [http://codex.wordpress.org/Template_Hierarchy](http://codex.wordpress.org/Template_Hierarchy))
 *  Thread Starter [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708247)
 * Yes it is. I changed the reading to show 1 post and syndication feed 1 as well
   and now its posting the 6 containers but with the page-navigation (21 pages).
   How would I remove the blocks out of the loop? Would you recommend creating a
   static index page with the blocks?
 *  Thread Starter [Shay](https://wordpress.org/support/users/shaypessah/)
 * (@shaypessah)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708248)
 * This actually worked: [http://pastebin.com/qXerQr9D](http://pastebin.com/qXerQr9D)
 * I removed the loop from the page.
 * Thank you so much for your help!!
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708249)
 * > Would you recommend creating a static index page with the blocks?
 * that would make sense – to create a page template with the code;
 * [http://codex.wordpress.org/Pages#Page_Templates](http://codex.wordpress.org/Pages#Page_Templates)
 * [http://codex.wordpress.org/Creating_a_Static_Front_Page](http://codex.wordpress.org/Creating_a_Static_Front_Page)

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Index Posts duplicating indefinitely.’ is closed to new replies.

## Tags

 * [index](https://wordpress.org/support/topic-tag/index/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [post categories](https://wordpress.org/support/topic-tag/post-categories/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/index-post-repeating/#post-2708249)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
