Home Forums Backend Issues (wp-admin) Removing Attachment post_parent on File Field Type


Removing Attachment post_parent on File Field Type

  • I have a Repeater Field which allows a user to upload up to three Files using the File Field Type. This works fine, and allows me to upload up to three files.

    The problem is that when editing a post, if I upload a file into the repeater field, and then later remove this same file, it remains associated in the wp_posts table with its post_parent set to the ID of the post it was uploaded to.

    For my specific use in this site, I would like to remove this association (i.e., set the post_parent = 0 for the attachment) whenever a file is removed from a post repeater field. Alternatively, I’d like to delete the file all together if it is removed from the post; I can’t count on my users to clean up the files they upload but decide not to use.

    What hook can I use to alter this functionality?

  • I was able to get around the issue I’d encountered by simply only referring to files actually being saved to the post, instead of files associated with the post.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.