Nested loops and resetting post data
|Reported by:||ericlewis||Owned by:||nacin|
|Severity:||normal||Keywords:||has-patch needs-testing has-unit-tests|
While building a custom loop, developers currently only have one function to reset post data - wp_reset_postdata(). This function resets the $post globals and thereby template tags to the original queried object in the $wp_query global. That's great, but not when it comes to nested loops. Using this function when you're deep within a nest of custom loops would mean upon exiting a loop, calling this function resets to the original queried object, although you're still within a loop that has posts related to it.
Change History (16)
comment:5 wonderboymusic — 4 months ago
- Keywords needs-testing needs-unit-tests added; dev-feedback removed
- Milestone changed from Awaiting Review to 3.7