title: Adding Post With Featured Image Programmatically
body: <p>I am adding posts dynamically to wordpress. I am using following code to create post and add a featured image which is working fine but there are 2 problems </p>
  
  <ol>
  <li>It adds 2 posts 1 with image itself no other content and correct with post with that image as featured image .  </li>
  <li><p>Featured image in post size large .</p>
  
  <p>$post_id = wp_insert_post( $postdata, true );<br>
           //Saving  Image from a url<br>
           $attachmentId_id = wp_insert_attachment( $attachment,$fullpathfilename,0);<br>
          add_post_meta( $post_id, '_thumbnail_id', $attachmentId, true );</p></li>
  </ol>