S3nd41
Member
Posted 4 months ago #
Hi guys,
I'm trying to get a nested loop working that will display 6 posts with a certain code, then go back, display the same 6 posts with a different code and then continue doing this until there are no more posts.
Can anyone give me some pointers on how this can be accomplished? I tried searching the forums but the solutions are really specific and I'm not sure how to adapt them.
Thanks!
http://codex.wordpress.org/The_Loop#Multiple_Loops
you might need to use rewind_posts() http://codex.wordpress.org/Function_Reference/rewind_posts after each loop; and possibly use the 'offset' parameter for the query http://codex.wordpress.org/Class_Reference/WP_Query
and all of that in a foreach or while loop ...
just checking: you mean:
A B C D E F a b c d e f
G H I J K L g h i j k l
M N ...
are you working with a particular theme?
S3nd41
Member
Posted 4 months ago #
No, I'm building my custom theme.
I've found some code that I've adapted and so far I've managed to get the loop to repeat twice on the first 6 posts, but after those first 6 it simply loops the remaining posts one time.
Here's the code:
http://pastebin.com/hBkYvy6U
The problem is that the second loop is only looping once after the first one prints the first 6 posts, how could I adapt this so that the second loop executes everytime?
[No bumping. If it's that urgent, consider hiring someone.]
you need to reset the $counter or check for a multiple of 6 with some code like if( $counter%6 == 0 )
S3nd41
Member
Posted 4 months ago #
It's not urgent but somewhat like 90% of the threads I create/participate in remain unanswered, (either general threads or plug-in support requests). No point in creating a forum if there's no actual participation from the community, I think. That put, thanks for the tip!
S3nd41
Member
Posted 4 months ago #