title: How to get Last post Id of custom post type in wordpress
body: <p>I want to get the last post id of a custom post type in WordPress. For this, I tried this code-</p>
  
  <pre class="lang-php prettyprint-override"><code>$args = array(
      'post_type' =&gt;'soto_property',
      'posts_per_page' =&gt; 1,
      'orderby'=&gt;'post_date',
      'order' =&gt; 'DESC',
  );
  
  $image_posts = get_posts($args);
  foreach ( $image_posts  as $post ) {
      echo $post-&gt;ID;
  }
  </code></pre>
  
  <p>But It always returns me the First post id of this custom post type. I have tried <code>'order'=&gt;'ASC'</code> also but it gives me the same result.</p>
  
  <p>How can I achieve the last post id of this CPT?</p>