Home › Forums › ACF PRO › Dropdown select to output specific dataset from another pages field group values
What I’m trying to accomplish is to use values gathered from a main location page on separate pages. The catch is there will be many location pages and I need to select, in the page editor, which locations value(s) to grab, for display, using a select item containing the groups title so I can select the appropriate one.
Example. Field Groups appear in page editor when home_template is assigned. Many home_template’s may be assigned and store their unique datasets. For each set of values filled out, I want to be able to grab the values from any page that creates this dataset, and output them into the header.php or page.php using get_field(‘group_value_one’), possibly also via shortcode output so I can place the values in the editor. So there may be many values to that get_field, but in the editor I have already selected which locations dataset to grab. So if no location is selected, no data is pulled through. If a location is selected that locations data will pull through.
Further explanation, on location-page-1 I fill out the location name, address, phone and hours and save. On location-page-2 I fill out the location name, address, phone and hours and save. Then I go to random-page-1 and choose from a dropdown(select), automatically populating the location data sets I created, by Location Name. If I choose the selection for location-page-1, it outputs, via coded php, the dataset values for Location 1 on the page in the frontend. In order to place it somewhere I will probably end up using a shortcode to display the info. But each page needs to be able to fetch the data from the page it was created on and output only the selected locations information.
In the images attached you’ll see I tried the relationship field but not really sure what it’s for or how to use it. May not be needed at all, not sure. I am able, but amateur with ACF and maybe intermediate with PHP.
Very clear and simple to follow instructions are much appreciated. Thank you.
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.