Dynamic Content from ACF Options page

I’ve created the ACF Options page using this method: https://www.advancedcustomfields.com/resources/options-page/
I have some custom fields showing in that options page related to button text.

What I can’t figure out is how to get those custom fields to show in the dynamic content of my button.

So far I can get the ACF field to show in the button text using the Field Key, but when I change the field via the Options page the text doesn’t get updated on the front end - I think because the Field Key is reading directly from the Field Group instead of the options page.

I hope this makes sense - ACF/Dynamic Content is all a bit new to me so please let me know if I need to clarify.

This ACF page may give some more clues but I couldn’t figure it out: https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/

Thanks!

Hi @marketfresh,

Please make sure you’ve added the 'option' after the field key.

Here is an example:

<?php echo get_field('your_field_key', 'option'); ?>

Hope it helps :slight_smile:

Ok, but how does that look in the context of how Pro does dynamic content?
Here is the code I’m currently using in the Button Text field:

{{dc:acf:field field=“field_5c913dba5fbf6”}}

Hi @marketfresh,

It should be like this: {{dc:acf:field field="location" post_id="options"}}

The location is your field name.

For more information, please take a look at this:

Hope it helps :slight_smile:

It’s not working.
I also tried {{dc:acf:field post=“options” field=“book_now”}}

Any other suggestions? Do you want login credentials to take a look?

Hi Jonathan,

I don’t think you can combine the two, the ACF is dynamic itself. Dynamic content of the builder could only pull the data that are built-in to Wordpress (not by other plugins). Example, post content, title, and so on. But if this is true,

Then you can simply implement it as custom meta

resulting to {{dc:post:meta key="location" post="322"}}

Thanks!

1 Like

Does that mean the ACF Options is a post type? If so, what is the post id?

Hi Jonathan,

You can get the post id from the url. Please check the link below for your guide.

Thanks

This is the Options page URL: /wp-admin/admin.php?page=acf-options
This is why I asked what the post id is - it’s not in the URL.
It would be great if you guys could test the functionality that I’m looking for or ask a dev to see if its even possible. And if it’s not, it would be a great feature.

Thanks!

Hey There,

​To assist you better with this issue, would you mind providing us the url of your site with login credentials so we can take a closer look? This is to ensure that we can provide you with a tailored answer to your situation.

To do this, you can create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out: https://theme.co/apex/forum/t/how-to-get-support/288

Thank you.

If you go to the Rafting page, you’ll see the “Book - Pay Now” button. Right now the button text is being pulled directly from the custom field: Custom Fields > Field Groups > Package Buttons > Book Button

I would like the text to be pulling from the Options instead: Options > Book Button > “Book - Pay Now!”

I just added an exclamation mark to the Book Button filed in the Options so we can see the difference when it’s pulling from the options page.

Hello Jonathan,

We have successfully logged in to the site. We cannot edit the page and check your settings at the moment because we are seeing these errors:

Warning: file_get_contents(/usr/home/mtwhitewater/public_html/yellowstoneraftzipline.com/new/wp-content/themes/pro/settings.json): failed to open stream: No such file or directory in /usr/home/mtwhitewater/public_html/yellowstoneraftzipline.com/new/wp-content/themes/pro-child/lib/init.php on line 7

Warning: require_once(/usr/home/mtwhitewater/public_html/yellowstoneraftzipline.com/new/wp-content/themes/pro-child/lib/plugins/TGM-Plugin-Activation/class-tgm-plugin-activation.php): failed to open stream: No such file or directory in /usr/home/mtwhitewater/public_html/yellowstoneraftzipline.com/new/wp-content/themes/pro-child/lib/init.php on line 189

Fatal error: require_once(): Failed opening required '/usr/home/mtwhitewater/public_html/yellowstoneraftzipline.com/new/wp-content/themes/pro-child/lib/plugins/TGM-Plugin-Activation/class-tgm-plugin-activation.php' (include_path='.:/usr/local/lib/php') in /usr/home/mtwhitewater/public_html/yellowstoneraftzipline.com/new/wp-content/themes/pro-child/lib/init.php on line 189

If you have added any custom code, please remove or fix it first. Thanks.

Was working on it. Those errors are gone now.

Hello There,

The page does not load in the editor because of your custom JS code from a file: … /wp-content/themes/pro-child/js/script.js?ver=5.1.1

Uncaught ReferenceError: SiteVars is not defined
    at Object.filterStaffUpdateUrl (script.js?ver=5.1.1:73)
    at Object.init (script.js?ver=5.1.1:13)
    at HTMLDocument.<anonymous> (script.js?ver=5.1.1:1220)
    at i (jquery.js?ver=1.12.4:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
    at Function.ready (jquery.js?ver=1.12.4:2)
    at HTMLDocument.K (jquery.js?ver=1.12.4:2)

By the way, are you using the ACF pro in the button? Regretfully ACF options is not supported in the button or elements in the editor.

Regards.

I’ve removed that script. Can you check again?
This is what I have currently in the button: {{dc:acf:field field=“field_5c913dba5fbf6”}}
This is pulling the button text directly from the ACF Field, specifically the “Default Value” field.

I’d like for it to instead pull from the Options filed that references that ACF field.

Hello Jonathan,

Options > Book Button > “Book - Pay Now!” is not connected to your pages. Only the Custom Fields > Field Groups > Package Buttons > Book Button is connected to the page. The ACF options page primary is to provide a set of functions to add extra admin pages to edit ACF fields.

All data saved on an options page is global. **This means it is not attached to any particular post or page**, but is saved in the wp_options table. This allows the data to be displayed on any page throughout the website (good for header and footer data)!

Hope this helps.

@RueNel, @Rad, @thai
Ok, but if I do this in a template file: <?php the_field('book_button', 'options'); ?>
it actually pulls the text from the field on the Options page. I was just hoping I could do the same thing via the Dynamic Content functionality.

If not possible, it would be a nice feature to add since most site owners will find it easer to edit the fields in the Options page rather than dig around ACF to do it.

1 Like

Hello Jonathan,

Please try this: {{acf:book_button post_id="option"}}.
Otherwise, it might not possible as of this moment. We can added this as a feature request so it can be taken into consideration for future development.

Thanks for the feedback.

It doesn’t work. I also tried a few variations like
{{dc:acf:book_button post_id=“option”}}
{{dc:acf:book_button post_id=“options”}}
{{dc:post:meta post=“options” key=“book_button”}}

Thanks for putting it in as a feature request.

No problem.
If you need anything else we can help you with, don’t hesitate to open another thread.