Multiple loops
-
(I THINK that’s the version of WordPress I’m using– not sure).
To make a long story slightly less long: I have created a second loop on single.php of twentyeleven to display all posts underneath the single post that the user may navigate to…
It worked, but I am confused… Every resource (including the codex) suggests either resetting the loop’s counter with?putting rewind_posts(); before the start of the second loop, and/or putting either wp_reset_postdata(); or wp_reset_query();
after the 1st endwhile;, and also putting both loops into their own variables ($myloop = new WP_Query for example)…During trying to implement a second loop on single.php I have discovered that out of all the above, the only thing that was needed was for the second loop to be stored in its own variable (code worked fine regardless of how i chose to reset the loop counter…I even tried it without resetting the counter and it STILL WORKED).
My question about the above is: why is it still working?..kinda ironic, but i must be doing something wrong or misunderstanding something if it still works considering my deliberate deviations
[mod: moved to ‘Miscellaneous’]
- The topic ‘Multiple loops’ is closed to new replies.