{"id":3935693,"date":"2013-07-16T21:31:34","date_gmt":"2013-07-16T21:31:34","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/nested-loop-2\/"},"modified":"2016-08-21T03:00:14","modified_gmt":"2016-08-21T03:00:14","slug":"nested-loop-2","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/nested-loop-2\/","title":{"rendered":"Nested Loop"},"content":{"rendered":"<p>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 &#8220;sprinkle&#8221; 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.<\/p>\n<p>post1 post2 post3 testimony1<br \/>\npost4 post5 post6 testimony2<\/p>\n<p>I would actually like the testimonys to display randomly but I think having it like this may be easier. <\/p>\n<p>The problem I am having is the first loops &#8216;while&#8217; 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.<\/p>\n<p>I have tried nested loops as well as combing both post types in a single loop with no luck.<\/p>\n","protected":false},"template":"","class_list":["post-3935693","topic","type-topic","status-closed","hentry","topic-tag-custom-post-type","topic-tag-nested-loop"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3935693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3935693\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=3935693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}