Support

Home Forums Event Espresso Premium Display upcoming events

Display upcoming events

Posted: June 20, 2016 at 8:50 am

Viewing 3 reply threads


SapphireBSL

June 20, 2016 at 8:50 am

Hi

I would like to display 3 (or however many) upcoming events on my homepage. Something along the lines of:

A PHP Loop to display 3 events
<div id=”Event Title”> ######### </div>
<div id=”Event Date”> ######### </div>
<div id=”Event Price”> ######### </div>
<div id=”Event Excerpt”> ######### </div>
<div id=”Event Link>Book Online</div>

Are there shortcodes I can use to do this. If not would you share the bits of code I need to pull into my php.

Thanks


Tony

  • Support Staff

June 20, 2016 at 4:01 pm

Hi there,

We do not have shortcodes to pull in each of those individual sections, however EE posts are Custom Post types (with some additional information) so you can create a similar loop that you would normally use for posts.


@Josh
has an example of a simple event list here:

https://gist.github.com/joshfeck/6e33532c37a123bbf532

You can also use the get_upcoming_events() to pull in all your upcoming events like this:

$events = EEM_Event::instance()->get_upcoming_events( 
    array( 
        'order_by' => array( 'Datetime.DTT_EVT_start' => 'ASC' )
    )
);

$events will be an array of your upcoming EE event posts.

Is that what you are looking for?


SapphireBSL

June 27, 2016 at 2:49 am

Hi All

Is there somewher in the documentation that will tell me what the field names within the array are?
e.g. $event->name() = Event Name
So Event Title, Date, Price, Excerpt, Link would be …


Josh

  • Support Staff

June 28, 2016 at 7:28 am

You’ll find examples in the developer documentation:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/ee-model-objects-and-custom-post-types.md

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-querying.md

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/using-ee4-model-objects.md

Viewing 3 reply threads

The support post ‘Display upcoming events’ 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