I want to add facts to a custom post type using ACF. On the actual page, only one of the facts will be displayed, chosen at random from 5-10 per CPT.
Which ACF field could I use to achieve this? I essentially need to list 5-10 different facts, and have a way to use the_field() or get_field() to grab just one of those facts.
My initial thought was to just use a Text Area field and separate facts by a special character, then write some code to parse out which fact gets selected, but that seems a bit more complicated that what I should need. Is there any organized way to do this with ACF? Note that this is just one aspect of the page, and I don’t want 10 fields.
You should consider using a repeater field with a text field for a subfield.
Then check out this tutorial which allow you to query the repeater subfield values.
Hope this helps 🙂
Thanks for the information, James. I hadn’t used the repeater fields yet, but that seems like a perfect use of them. I also just discovered the tabs field, which will be great for organizing the information on the back end.
My only minor hiccup here will be simply grabbing every item of the repeater field, not just specific ones. That tutorial threw me off a bit with the Images repeater field, images, and type, as the type bit doesn’t apply to me. I was reading it in a rush, so it should be a lot easier than I’m making it, but if you have any quick advice on that, I’m open to it. Otherwise, I’m sure I’ll figure it out. Thanks again!