Display custom date fields based on event category


I am using the Event Organiser plugin and when I add the loop around the date fields it shows the current date and time, as opposed to the event start and end times. When I remove the loop it shows correctly. So I think something needs a tweak, this is what I have so far.

<div class=eo-date-time-events>
  <Loop taxonomy=event-category exclude=exhibition post=current>
      <Date format="l, F j, Y"><Field _eventorganiser_schedule_start_start /></Date> at <Date format="g:i a"><Field _eventorganiser_schedule_start_start /></Date>
<div class=eo-date-time-exhibition>
  <Loop taxonomy=event-category include=exhibition post=current>
      <Date format="F j, Y"><Field _eventorganiser_schedule_start_start /></Date> to <Date format="F j, Y"><Field _eventorganiser_schedule_start_finish /></Date>

Any advice would be greatly appreciated. Thanks!

Hey Dana! I think the reason you’re running into that issue is that the _eventorganiser_schedule_start_start field exists on the current post so when those Date/Field tags are placed on the template directly (i.e. not in a loop), that field exists on the current post so your markup works correctly. But when you create a taxonomy term loop, then your Field tag is trying to get the _eventorganiser_schedule_start_start field from the current taxonomy term being looped through. But that field obviously doesn’t exist on your taxonomy term so since nothing is being fed to the Date tag, the current date gets displayed.

One solution here could be to save the field as a variable and then refer to that variable inside your taxonomy term loop, but it might be better for performance if you can rewrite your template a bit depending on what you’re actually trying to achieve with that taxonomy term loop.

Let me know if you have any issues getting that working!

Edit: I just made a whole write up to better explain the importance of context in L&L over in this forum reply. You might find that useful if you want to dive a little deeper into why your markup wasn’t working.