Support

Home Forums Event Espresso Premium espresso_event_date using the first date of an event instead of the upcoming one

espresso_event_date using the first date of an event instead of the upcoming one

Posted: October 15, 2015 at 6:37 am


Joren

October 15, 2015 at 6:37 am

Hello, I have a custom EE_Event_List_Query that I’m running on the home page of http://www.simpleque.com/ if you scroll down a bit.

I just now noticed that the events are all in the correct order by their upcoming dates, but it’s showing the first dates of each specific event instead of the actual upcoming dates. How can I fix that?

I’m currently just pulling the dates using espresso_event_date()


Josh

  • Support Staff

October 15, 2015 at 7:45 am

Hi Joren,

It turns out that the espresso_event_date() template tag is designed to return the first date (or primary) of an event. Instead of using the espresso_event_date() tag, you can loop through all of the dates and grab the next upcoming date. This is some example code that’s used by some of the Event Espresso add-ons to do the same thing:

<?php
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
$datetime = end( $datetimes );
$startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );
?>

Then to display it:

<?php echo $startdate; ?>


Joren

October 15, 2015 at 8:14 am

Perfect, thanks!

The support post ‘espresso_event_date using the first date of an event instead of the upcoming one’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso