This members-only tutorial provides the steps to define a custom function that returns the value of specified sub field inside a group on an ACF Options page so that the sub fields values' can be inserted via the Dynamic Data feature of Oxygen.
Step 1
Install and activate Advanced Custom Fields Pro plugin.
Let's enable ACF Options page.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: Enable ACF Options Page
Code:
if ( function_exists( 'acf_add_options_page' ) ) {
acf_add_options_page();
}
Step 2
Add a new field group labeled say, "Sitewide".
Add a new field labeled say, Business Settings
and set its field type to Group.
Add your desired sub fields.
In this example, let's add phone
and business_hours
.
Set the field group to appear on the Options page.
Here's the field export from my test site. Alternate download link.
Step 3
Populate your sub fields on the Options page.
Business Hours field content from my test site:
<div class="business-hours"><span class="day">Mon:</span><span class="opening-hours">9 am to 5 pm</span></div>
<div class="business-hours"><span class="day">Tue:</span><span class="opening-hours">9 am to 5 pm</span></div>
<div class="business-hours"><span class="day">Wed:</span><span class="opening-hours">9 am to 5 pm</span></div>
<div class="business-hours"><span class="day">Thu:</span><span class="opening-hours">9 am to 5 pm</span></div>
<div class="business-hours"><span class="day">Fri:</span><span class="opening-hours">9 am to 5 pm</span></div>
<div class="business-hours"><span class="day">Sat:</span><span class="opening-hours">1 pm to 4 pm</span></div>
<div class="business-hours"><span class="day">Sun:</span><span class="opening-hours">Closed</span></div>
Step 4
Time to define our custom function.
Add another Code Snippet.
Title: [Function] Return Business Settings Sub Field Values
Code:
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $599 one-time).
Already a member? Log in below or here.