Nested loop or saving state?
-
I’d like to create this list of PDFs – under the 2025 bulletins heading – by using DisplayPosts to loop through the corresponding attachments (from the Media Library).
The issue is that the typically two or three links per Sunday are offset by a blank line before and after.
I could accomplish that either through nesting loops –
for date = first sunday through last sunday
for service in date.services
<print text and link for service.bulletin>
end service
end dateor by
previousSundayDate = "xxx"
for service = first service of the year through last service of the year
thisSundayDate = service.SundayDate
if previousSundayDate <> thisSundayDate
<print offset>
<print text and link for service.bulletin>
previousSundaydate = thisSundayDate
end service
How do I accomplish either with DisplayPosts? Part of the answer may lie in https://displayposts.com/2019/01/04/enable-display-posts-within-post-listing/
but the way I read that I would have to create a bunch of posts, one for each Sunday, using DisplayPosts to loop through the Bulletins for that Sunday, and then loop through the bunch of posts. Seems cumbersome, since I don’t need the individual posts, one for each Sunday.
The page I need help with: [log in to see the link]
The topic ‘Nested loop or saving state?’ is closed to new replies.