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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Joren 4 years, 1 month ago ago

Topic Tags

Tagged: ,

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!
[for="input_96_5_3"]
[for="input_96_5_3"]
[gravityform id=96 title=false description=false]
  • This field is for validation purposes and should be left unchanged.
[i]
[i]
[gravityform id=69 title=false description=false]
  • This field is for validation purposes and should be left unchanged.