Home › Forums › Add-ons › Repeater Field › Get content of sub-fields based on a.. subfield!
Hey there,
I am trying not to make it too complicated, so I’ll explain right away, maybe you have a better idea to approach this. 😀
For a customer’s project I have a team page with a normal content field, plus a repeater field with information about their team members (e.g. name, function, about text, social links). My customers want to be able to use those infos to put a customised bio (with the fields mentioned) under a blog post or a page of their choice, thus by picking a single instance of the repeater field.
My idea was to write a shortcut, in some way, that enables them to use these repeater instances, e.g. they write [bio John Doe] and have their bio inserted. Alternatively, an option field (via ACF) below each page and post to freely pick a bio if needed (and none if nothing was picked) would fit well. But how to do any of these two things with ACF? Does anybody have an idea?
Best
physalis
Hi @physalis
A shortcode would work great.
It would need to load the team page’s repeater field (hardcode the $post_id parameter) and loop over the rows to match the ‘name’.
once a match is found, return the data of the current row.
Easy
Thanks
E
Hi elliot, you one-of-a-kind support guy :),
that sounds fine and reasonable – only I am too little a programmer to know how to actually do it. Could you give me a hint, if this is not asked too much? I may get around my head to get to loop the rows (I of course did that already, though not with hardcoded post IDs), but wouldn’t really know how to match the ‘name’ field and have it incorporated into a shortcode as a parameter (like in my [bio John Doe] example).
If this is way above what you could offer here, please don’t refrain from telling me!
Best
physalis
Hi @physalis
Sorry mate, the above will require quite a lot of time to demonstrate the PHP needed to accomplish the task. Perhaps you could hire a web developer and brief them on the task?
Thanks
E
Hey there,
thanks for letting me know. I am already checking it out, so thanks for helping me so far!
Best
Eno
The topic ‘Get content of sub-fields based on a.. subfield!’ is closed to new replies.
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.