Support

Home Forums Event Espresso Premium espresso_get_events() help

espresso_get_events() help

Posted: October 17, 2014 at 11:10 pm


steeleb88

October 17, 2014 at 11:10 pm

I’m having trouble looping through the results of this function. It returns the events I need to display, however, I can’t quite quite figure out how to access the event name, date, and description field. Could someone be so kind as to post a code example? This is where i’m at..


$posts_array = espresso_get_events(array(
    'limit' => 4,
    'order_by' => 'start_date',
));
if(!empty($posts_array)){
    foreach($posts_array as $post){
        $event_obj = $post->EE_Event;
        if($event_obj instanceof EE_Event){
            echo $event_obj->EVT_ID;
        }
    }
}


Dean

October 20, 2014 at 12:29 am

Hi,

Try something like this:

$posts_array = espresso_get_events(array(
    'limit' => 4,
    'order_by' => 'start_date',
));

//var_dump($posts_array);

if(!empty($posts_array)){
    foreach($posts_array as $post){

    	echo '

' . $post->post_title . '

'; echo '

' . $post->DTT_EVT_start . '

'; echo '

' . $post->DTT_description . '

'; } }

You can uncomment the var_dump to see what data is available to query.


steeleb88

October 20, 2014 at 1:50 pm

Thank you!


steeleb88

October 20, 2014 at 2:43 pm

Actually, I have another question.. How come you are not getting data from the WP_Post object and not from the EE_Event object? Like EVT_ID, EVT_desc, EVT_name, etc.? Are those accessible?


steeleb88

October 20, 2014 at 2:51 pm

Pardon me, “FROM the WP_post object and not the EE_Event object”


Lorenzo Orlando Caum

  • Support Staff

October 20, 2014 at 4:06 pm

Hi,

Events and Venues are stored in the wp_posts db table with supporting information in other Event Espresso db tables (wp_esp_). Please see this page:

http://developer.eventespresso.com/docs/ee-model-objects-and-custom-post-types/


Lorenzo


steeleb88

October 20, 2014 at 4:28 pm

Perfect! Thanks!

The support post ‘espresso_get_events() help’ 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