Support

Home Forums Event Espresso Premium EE4 Events Loop on Homepage

EE4 Events Loop on Homepage

Posted: October 17, 2014 at 8:29 pm


steeleb88

October 17, 2014 at 8:29 pm

Hello, I’m looking to build a section on my homepage with a view of the next 4 upcoming events. How can I pull these back and loop through an array of events? Is it a DB call or is there a global $events variable ? I would rather not create a plugin for this.


steeleb88

October 17, 2014 at 8:36 pm

by DB call i mean WP_Query. Is this the best way to pull back upcoming events?


steeleb88

October 17, 2014 at 9:04 pm

I used this from the widgets.php file and it worked..

                $where = array(
					'status' => 'publish'
				);
                $events = EE_Registry::instance()->load_model( 'Event' )->get_all( array(
					$where,
					'limit' => '0,4',
					'order_by' => 'Datetime.DTT_EVT_start',
					'order' => 'ASC',
					'group_by' => 'EVT_ID'
				));
                print_r($events);

is this a reasonable approach?


steeleb88

October 17, 2014 at 9:58 pm

I’ve found some useful public functions in /public/template-tags.php. Believe I’ve answered my own question.

The support post ‘EE4 Events Loop on Homepage’ 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