Do custom post type (CPT) attachments/media store the parent post ID?

custom post type attachments

There are only attachments, this phrase does not make sense and is not something that is possible. When you upload a file, a post of type attachment is created.

This attachment is attached via post parent. An attachment with no post parent is unattached.

ACF will be creating a post of type paper, whose post ID is provided as the parent. There are 2 posts here. A paper post, and an attachment post that is attached to it. Attachments are just attachments, they work the same everywhere, it does not matter what the type of the post it’s attached to is. You get the parent the same way you get any other post, there should be no special step just for CPTs ( CPT’s are just post types that don’t come with WP by default, the custom part is that your code registered it, not core, otherwise they are stored work and behave the same way ).

For those interested, this is my current code in functions.php which results in nothing being added to the front of the file name.

The problem now is that you’re trying to interface with a bespoke 3rd party plugin that may or may not provide this post ID.

In the strictest sense, the only canonical general WordPress answer is that there is no post parent, the attachment post has not been created yet, we do not know.

I’m sorry if I’m breaking protocol by posting here as well. But if I can establish that getting the CPT post id is possible at the point of creating the post and uploading file I can at least continue trying to get the code to work.

To get the answer/solution you want, you will need ACF help, not WordPress help. You need to contact ACF support, ACF developers, and ACF users. ACF knows which post it needs to be attached to, so how does it know that information? That’s what you need to ask.