Title: Get post_id
Last modified: December 13, 2016

---

# Get post_id

 *  Resolved [ositive](https://wordpress.org/support/users/ositive/)
 * (@ositive)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/get-post_id/)
 * Hi
    I would like to get the post id list (i.e. comma-separated) from the posts
   filtered with $arg. I know that if I use the get function (below), I obtain all
   the post attribute values filtered with $arg array values: how can I get the 
   post_id (as said, i.e. comma-separated) from $dd?
 * $dd = EM_Events::get( $args );
 * Thanks
    Ositive

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/get-post_id/#post-8550872)
 * you can try something like
 *     ```
       $events = EM_Events::get( $args );
       foreach ( $events as $EM_Event ){
         echo $EM_Event->post_id;
       }
       ```
   
 *  Thread Starter [ositive](https://wordpress.org/support/users/ositive/)
 * (@ositive)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/get-post_id/#post-8554024)
 * Thanks!
    I used the following code: $events = EM_Events::get( $args ); foreach(
   $events as $EM_Event ){ echo $EM_Event->post_id .”;”; }
 * obtaining var_dump($EM_Event) equal to “847;190;187;476;822;NULL”
    the problem
   is that I need a string, in order to pass it to my shortcode, but $EM_Event is
   not a string: How can I get the string like “847;190;187;476;822” from $EM_Event?
 * Thanks
    Ositive
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/get-post_id/#post-8556643)
 * Try:
 *     ```
       $my_string = '';
       $events = EM_Events::get( $args );
       foreach ( $events as $EM_Event ){
       $my_string .= $EM_Event->post_id .';';
       }
       ```
   
 *  Thread Starter [ositive](https://wordpress.org/support/users/ositive/)
 * (@ositive)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/get-post_id/#post-8562623)
 * It works great! thank you!
    I’ll try the same approach for the other templates!
   Thanks Ositive

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Get post_id’ 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/)

 * 4 replies
 * 3 participants
 * Last reply from: [ositive](https://wordpress.org/support/users/ositive/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/get-post_id/#post-8562623)
 * Status: resolved