Home › Forums › ACF PRO › Dynamically fill in custom fields depending on the value selected from a dropdow
Hi there!
I have the following idea in my head and I want to see if this is possible:
I have a Field Group called “AuthorBio”. This field group has fields with Author Name, Short Bio, Photo, and optional links to social media profiles.
I use this field group in a CPT called “ReviewsCPT”. This CPT is used for book reviews, and I use the info from AuthorBio to display the author info on all reviews.
The problem I’m facing right now, I have to manually fill in the AuthorBio every time I create a new review, even if I’ve already done this for the author previously. If I review 5 books by the same author, I have to manually fill in AuthorBio every time.
What I would like to do is create a new CPT, let’s call it AuthorsCPT. In that CPT, I fill in all of the author info that is needed by the “AuthorBio” field group. In AuthorsCPT I just use core WP features: title, featured image and post content. I’m not using custom fields (I could, if needed)
However, I don’t know how to link the info in the AuthorsCPT so that I can display it in ReviewsCPT through the “AuthorBio” field group.
Is there a way using ACF to add a search box or Select box that will let me choose an author I’ve already created in AuthorsCPT, and it will automatically fill in the info in the “Author Bio” field group when creating a new review?
So the process would be:
1) Fill in the author profile in AuthorCPT, with name, bio, featured image. Let’s say Agatha Christie
2) Create a new Review (in ReviewsCPT) for a book by Agatha Christie
3) In a search or Choice > Select field type, search “Agatha Christie”
4) This selection should automatically fill in all fields in the “AuthorBio” field group with Agatha Christie’s name, bio, photo
I understand that this sounds a bit complicated, and I’ve tried my best to make it as clear as possible, but if you need any further info, please let me know.
Also, if there’s a simpler workaround, I’m all ears 🙂
Thanks,
Rafael
This can be done using a post object field or a relationship field. There is no need to store this information in both the author CPT and the review. You would select the author when created the review and then in your template you get the data from the post selected in the relationship field. Storing duplicated data for every review is generally a bad idea.
You must be logged in to reply to this topic.
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.