Title: Get events custom WP_Query
Last modified: June 13, 2023

---

# Get events custom WP_Query

 *  Resolved [dabeecher](https://wordpress.org/support/users/dabeecher/)
 * (@dabeecher)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/get-events-custom-wp_query/)
 * hello,
 * I have a custom WP_Query which is grabbing the latest 5 events on my home page.
 *     ```wp-block-code
       $args = array(
               'post_type' => 'event',
               'post_status' => 'publish',
               'posts_per_page' => 5,
           );
   
           $loop = new WP_Query( $args );
           if($loop->have_posts()):
       ```
   
 * Within my loop can I grab the event instance and use things such as #**_EVENTDATES**
   rather than writing it all again myself.

Viewing 1 replies (of 1 total)

 *  [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/get-events-custom-wp_query/#post-16819840)
 * You could do something like this:
 *     ```wp-block-code
       $post = $loop->the_post();
       $postid = get_the_ID();
       $EM_Event = em_get_event($postid, 'post_id');
       $eventdate = $EM_event->output_dates();
       ```
   
 * Look in wp-content/plugins/events-manager/classes/em-event.php to see how the
   various placeholders are expanded out (e.g. #_EVENTDATES)

Viewing 1 replies (of 1 total)

The topic ‘Get events custom WP_Query’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/get-events-custom-wp_query/#post-16819840)
 * Status: resolved