Title: Nested Loop
Last modified: August 21, 2016

---

# Nested Loop

 *  [Juan Rangel](https://wordpress.org/support/users/nunotmp/)
 * (@nunotmp)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/nested-loop-2/)
 * I have been stumped on this and I am not entirely sure it can be done. I am wanting
   to combine 2 loops and and “sprinkle” the second loop through out the first loop.
   Some people do this with ads so they will have an ad show every few posts. What
   I am attempting to do is add a custom post type(testimony) show up every 3 normal
   posts. I will try to demonstrate this below.
 * post1 post2 post3 testimony1
    post4 post5 post6 testimony2
 * I would actually like the testimonys to display randomly but I think having it
   like this may be easier.
 * The problem I am having is the first loops ‘while’ is causing it to loop through
   the testimonies so they are repeated over and over as long as the main loop has
   posts. Does anyone know of a way to pull only one nested loop post at a time?
   I apologize if this sounds confusing if you need any clarification just let me
   know.
 * I have tried nested loops as well as combing both post types in a single loop
   with no luck.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/nested-loop-2/#post-3935809)
 * Have a look at [multiple Loops](http://codex.wordpress.org/The_Loop#Multiple_Loops)
   for some ideas.
 *  Thread Starter [Juan Rangel](https://wordpress.org/support/users/nunotmp/)
 * (@nunotmp)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/nested-loop-2/#post-3935845)
 * I have read through it several times. I cannot find how to keep the inner loop
   from duplicating its post as long as the parent loop has posts.

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

The topic ‘Nested Loop’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [nested loop](https://wordpress.org/support/topic-tag/nested-loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Juan Rangel](https://wordpress.org/support/users/nunotmp/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/nested-loop-2/#post-3935845)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
