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.

ACF field group having a group-type field with sub fields

Sub Fields filled with values on the Options page

Insert Data > PHP Function Return Value in Oxygen editor for phone sub field

Insert Data > PHP Function Return Value in Oxygen editor for business_hours sub field

Sub fields' values being output

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 ($37/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: