title: Wordpress - Link attachments to post with raw php sql query
body: <p>I'm working on a mobile version of a wordpress site (that will run on a subdomain and sharing the WP database), there is just a few static pages and 2 dynamic ones, one that lists WP posts and one with a form that allow users to post content with attachments. It's raw PHP so I'm not using WP functions; listing/creating new posts &amp; creating attachment was easy but I have an issue linking attachments to the post...</p>
  
  <p>When I post an attachment, I create an entry in wp_posts with an 'attachment' custom type and the parent ID set to the ID of the post I created before, then I create an entry in wp_postmeta with the attachement ID, the meta_key '_wp_attached_file' and the attachement path. </p>
  
  <p>The problem is that the attachment doesn't seem to be linked with the post... Actually, it doesn't even show up in the media library. So I guess there is something more to do but I can't find out what, any idea ?</p>