2

I have a custom-type post I'm trying to attach some audio/wav files to using the wp-admin UI.

When I upload the new files using the Add Media popup those get saved and embedded into the post just fine, but in the database those attachment-posts have parent_post set to 0.

It records the post_date and post_author correctly, but not the post_parent.

What is the reason for that behavior and how can I fix it?

Update ok so this only happens to the posts with custom post-type. When I upload the same audio file to the normal post it gets attached properly. If I try disabling the plugins it will remove that custom post type I'm working with and I won't be able to test.

Update2 this happens during the upload process. Here's the var_dump($_REQUEST); output from wp-admin/async-upload.php when uploading an attachment to the regular post:

array(4) {
  ["name"]=>
  string(42) "my_file.wav"
  ["action"]=>
  string(17) "upload-attachment"
  ["_wpnonce"]=>
  string(10) "457d8c9ee7"
  ["post_id"]=>
  string(4) "1234"
}

The post_id key is missing when I'm uploading an attachment to the custom post.

2
  • 1
    Does this happen with a vanilla WordPress installation with the default theme and no plugins? – Andrew Bartel Jan 28 '15 at 21:07
  • Thanks for the question, no, I should've mentioned this is a working Wordpress site with plugins. I will try to disable them all and see what happens – aexl Jan 29 '15 at 8:25
1

The reason was the post_id key simply missing from the upload query.

It was there for the normal posts, but was being omitted in the custom-post-type uploads. No idea why. The issue had something to do with the javascript uploader settings.

So I've asked another question regarding the pluploader here and have managed to find the solution myself.

I do not know why was the post_id being excluded, but at least it works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.