title: Getting ID from get_posts within a loop in Wordpress
body: <p>My first question here, so please feel free to direct me elsewhere (yes, I did try searching for duplicates, but my stackoverflow skills may be limited).</p>
  
  <p>I'm building a Wordpress plugin that creates a front-end dashboard to edit a custom post type. I'm using a get_posts query to display a list of the current user's posts, and their respective edit forms.</p>
  
  <p>The problem is that I cannot seem to access the post ID from the WP_Post Object. When I var-dump everything seems kosher....</p>
  
  <p>Here is my code (simplified) :
      $currentuser = get_current_user_id( );
          $args = array(
              'author' => $currentuser,
              'posts_per_page'   => -1,
              'post_type' => 'board_post', 
              );</p>
  
  <pre><code>$myposts = get_posts( $args );
  foreach ( $myposts as $jb_post ) : setup_postdata( $post ); 
  ?&gt;
  &lt;a href="#edit_&lt;?=$jb_post-&gt;id ?&gt;" data-toggle="modal" data-target="#edit_&lt;?=$jb_post-&gt;id ?&gt;" class="list-group-item"&gt; Edit &lt;/a&gt; &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>Nothing is outputted where the post ID ought to be.</p>
  
  <pre><code>&lt;?=get_the_title($jb_post); ?&gt;
  </code></pre>
  
  <p>That outputs the correct title.
  When I tried all of the following, it echoes the ID of the parent page : </p>
  
  <pre><code>&lt;?=get_the_ID($jb_post); ?&gt;
  &lt;?=the_ID($jb_post); ?&gt;
  &lt;?=get_the_ID(); ?&gt;
  &lt;?=the_ID(); ?&gt;
  </code></pre>
  
  <p>I presume that there is some sort of structural problem with the way I'm pulling up these posts. Throwing wp_reset_query doesn't adress the problem. Does anyone know of any resources regarding best practices for this sort of thing?</p>
  
  <p>EDIT: Here is the var_dump($jb_post)  </p>
  
  <pre><code>array(15) {
  [0]=&gt;
    object(WP_Post)#285 (24) {
      ["ID"]=&gt;
      int(253)
      ["post_author"]=&gt;
      string(1) "1"
      ["post_date"]=&gt;
      string(19) "2014-04-17 18:36:27"
      ["post_date_gmt"]=&gt;
      string(19) "2014-04-17 18:36:27"
      ["post_content"]=&gt;
      string(8) "gsdljdkf"
      ["post_title"]=&gt;
      string(10) "Shortcoded"
      ["post_excerpt"]=&gt;
      string(0) ""
      ["post_status"]=&gt;
      string(7) "publish"
      ["comment_status"]=&gt;
      string(6) "closed"
      ["ping_status"]=&gt;
      string(4) "open"
      ["post_password"]=&gt;
      string(0) ""
      ["post_name"]=&gt;
      string(12) "shortcoded-2"
      ["to_ping"]=&gt;
      string(0) ""
      ["pinged"]=&gt;
      string(0) ""
      ["post_modified"]=&gt;
      string(19) "2014-04-17 18:36:27"
      ["post_modified_gmt"]=&gt;
      string(19) "2014-04-17 18:36:27"
      ["post_content_filtered"]=&gt;
      string(0) ""
      ["post_parent"]=&gt;
      int(0)
      ["guid"]=&gt;
      string(51) "http://XXX.0.0.1:4001/wordpress/board/shortcoded-2/"
      ["menu_order"]=&gt;
      int(0)
      ["post_type"]=&gt;
      string(10) "board_post"
      ["post_mime_type"]=&gt;
      string(0) ""
      ["comment_count"]=&gt;
      string(1) "0"
      ["filter"]=&gt;
      string(3) "raw"
    }
    [1]=&gt;
    object(WP_Post)#284 (24) {
  (so on and so forth for all posts)
  }
  </code></pre>