Variable for Dynamic Content

Hi All - Is there a way to set a global variable that I can use in Dynamic Content?

I’m using ACF to gather content into a group of fields.

I want to create some reusable code - for a WP multisite setup - and I’d like the Post = “22” to be a variable I set globally so that I don’t need to change the code in 50+ locations per site when I move the templates/components into a new site. In this example the Post=“22” will change for each site, however the fields will stay the same as they share the ACF Field Group

//Current Code That Works
{{dc:acf:post_field post=“22” field=“field_69036ae5b7ea2”}}
{{dc:acf:post_field post=“22” field=“field_6903ae2594187”}}, {{dc:acf:post_field post=“22” field=“field_6903bb7ace2e1”}}

Can anyone help me with some insight on how to do this? I’m not a php programmer so mastering the API is not in my cards, however I can easily paste a bit of code into WPCode to make a variable available globally. My brain says this should be simple, but I’m stimied. Thanx

Hey Greg,

Thanks for writing in! I think I already replied to your ONE ticket regarding this idea. If I were to do something like this, I would set up an ACF Option field. I will then use a nested ACF dynamic content like shown below in my posts, pages, and components.

{{dc:acf:post_field post="{{dc:acf:option_field field="my-field-option-name"}}" field="my-field-name"}}

When I export and import the site, I would include the ACF option and the ACF fields as well so that this will work.

Hope this helps.

Ruenel –

This worked out very well and is currently being implemented. I wasn’t able to find this anywhere, so I’m sure it will be a good resource here for others.

Thank you!

You are most welcome, Greg.