Home › Forums › ACF PRO › Retrieve most recent front-end edited fields? › Reply To: Retrieve most recent front-end edited fields?
Wow, that is great. I didn’t realize the answer would be so involved!
Now I will throw this at you ;)…
I was thinking through this some more and was wondering if the easiest way would be to just create a custom post type of “Image Uploads” and then do the following:
– Each “Image Uploads” custom post type post would have the repeater field with the text area and image upload sub field and also a custom field that would be called “Associated Post”.
– When a regular post was created on the site, a new “Image Uploads” post would be automatically created as well. And the regular post would store the ID of the newly created “Image Uploads” post (in a custom field called “Associated Image Uploads”) and vice versa (the newly created “Image Uploads” post would store the value for the regular post in the “Associated Post” field). That way they would both know they are associated with one another.
– Then, when the regular post is displayed on the site I would be able to query that single custom post type “Image Uploads” post to display the images (using the ID stored in the “Associated Image Uploads” field).
– And then on the homepage, I would be able to just query all “Image Uploads” post types by most recent.
What are your thoughts on this method? Seems a lot less involved!
The only thing I am trying to figure out is how to associate the two posts together. So here are my questions:
1) How can I create a custom field on the regular post that would know the ID of the to-be-created “Image Uploads” post?
2) And similarly, how would I be able to have a custom field on the “Image Uploads” post that would know the ID of the post that created it?
It seems like I would need to create some kind of custom function that would run after a regular post is published that would automatically create the “Image Uploads” post and then update the regular post with that new “Image Uploads” post ID and also update the newly created “Image Uploads” post with the ID of the regular post that was just published. Correct?
Hopefully this all makes sense!
Thanks again for your help.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.