title: wordpress get_posts() returns empty the_ID()
body: <p>I've got a problem with loading a list of posts in a certain category via AJAX. the funny part is, that I get a right amount of posts, I get the excerpts right for each post, but ID, and title are empty, plus the date is wrong (1.1.1970). this is my function within functions.php:</p>
  
  <pre><code>function ajax_cat(){
  
  if( isset($_GET['action'])&amp;&amp; $_GET['action'] == 'ajax_cat'){
   $my_id = htmlspecialchars($_GET["id"]);
   $args = array(
                  'offset'          =&gt; 0,
                  'category'        =&gt; $my_id,
                  'orderby'         =&gt; 'post_date',
                  'order'           =&gt; 'DESC',
                  'post_type'       =&gt; 'post',
                  'post_status'     =&gt; 'publish' ); 
  
              $myposts = get_posts( $args );
              foreach( $myposts as $post ) :  setup_postdata($post); ?&gt;
                  &lt;div class="nadpis1" id="&lt;?php the_ID(); ?&gt;" &gt;
                  &lt;a href="#&lt;?php the_ID(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
                  &lt;span class="sipka"&gt;&lt;?php the_date("d.m. Y"); ?&gt;&lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div class="vnutro" &gt;&lt;?php echo the_excerpt();?&gt;&lt;/div&gt;
              &lt;?php endforeach; 
      die();
      }
  }
  </code></pre>
  
  <p>originally this code was inside the loop and worked well. this is what i get now:</p>
  
  <pre><code>&lt;div class="nadpis1" id="" &gt;
     &lt;a href="#"&gt;&lt;/a&gt;
     &lt;span class="sipka"&gt;01.01. 1970&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class="vnutro" &gt;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;&lt;/div&gt;
  
  &lt;div class="nadpis1" id="" &gt;
     &lt;a href="#"&gt;&lt;/a&gt;
     &lt;span class="sipka"&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class="vnutro" &gt;&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec adipiscing ultrices posuere. Aenean et egestas enim. Phasellus sit amet nisl elit. Sed pulvinar, purus nec commodo condimentum, lectus risus lacinia urna, sed ultrices magna est vitae turpis. Sed convallis pulvinar gravida. Sed non sem sem, at lobortis tellus. Etiam commodo risus vitae diam cursus volutpat. [...]&lt;/p&gt;&lt;/div&gt;
  
  &lt;div class="nadpis1" id="" &gt;
     &lt;a href="#"&gt;&lt;/a&gt;
     &lt;span class="sipka"&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class="vnutro" &gt;&lt;p&gt;gfdgdfsgngfjty ty jghj ty jtyhjghj dh gfdj5 fgjfdthbkdfgxhjsrgv ,f xfhbtyj dc rtjdtxhvcntydxvhctr shxfc&lt;/p&gt;&lt;/div&gt;
  
  &lt;div class="nadpis1" id="" &gt;
     &lt;a href="#"&gt;&lt;/a&gt;
     &lt;span class="sipka"&gt;01.01. 1970&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class="vnutro" &gt;&lt;p&gt;Vitajte vo WordPress. Toto je váš prvý článok. Môžete ho upraviť alebo vymazať a potom už len začať písať!&lt;/p&gt;&lt;/div
  </code></pre>
  
  <p>></p>
  
  <p>thanks for any suggestions!</p>