Support Forum
Support › Meta Box Group › Field Advanced and automatically "attach" uploaded file (e.g. pdf)Resolved
I use Field Advanced to upload pdf-files to posts of a custom post type. I just today realized that the uploaded pdf is not autmatically "attached" to the post, so I have to do it manually in /upload.php?mode=list (Media library) - there is a column called "Upload to" and there I have to click on "Attach" for each pdf I want to attach to specific posts.
Is it possible to specify an automatic attachment in the field definition? Or some other solution?
I need to "attach" pdf-files in order for SearchWP to be able to index and search content of pdf-files.
Hi,
The pdf files are automatically "attached" to the post after publishing/saving the post. If it does not work, can you please share some screenshots of the issue on your end?
Here are three images:
https://www.dropbox.com/sh/ccijd9mxcm33wjd/AAAaXvGRFHhvlVwrVyZgAckea?dl=0
(Is it not possible to attach the images directly in this reply?)
Hi,
I do not see any issue on my end, screen record https://share.getcloudapp.com/z8u1PYAO
But after saving the post and reloading the page, you see the file icon still available in the field that means the value is saved to the database. Don't worry about the attached option of WordPress.
You can also follow the documentation to output the field value to make sure it works https://docs.metabox.io/fields/file-advanced/#template-usage
If you add a pdf to a new, still unsaved/unpublished post, and then save/publish the post, you will see the problem! In your screen recording I think you add a pdf to a previously saved/published post. Therefore it works.
But maybe there is no way around this problem, except informing the user to save the post before adding the pdf? Or is there a script that can save the post in the background as soon as the title is written, or something like that?
The problem is, if the user forgets to save the post before adding the pdf, the pdf will not be searched by SearchWP, until it is manually attached in Media Library.
Here you go https://share.getcloudapp.com/yAu06Kb4
I've tested to create a new post (CPT), upload the PDF file, and publish the post. There is no issue like that. You can try to deactivate all plugins except Meta Box, switch to the standard theme of WordPress, and re-check this issue.
You are right! Maybe just a temporary glitch with my first two pdfs. I can't reproduce it any longer with new posts/pdfs.
Thanks!