[Solved] Dynamic Content API and Twig render error

Hi there,

I’ve added some custom dynamic content via the API (https://theme.co/docs/dynamic-content-api). I couldn’t find a change, but this method doesn’t work with the new Twig notation (see error below). It seems to be a problem with the key.

When I select a DC from the picker it defaults to the Twig notation instead of the old DC notation. So currently, I write all my custom DC by hand.

Is there a new documentation available for how to make custom dynamic content compatible with the twig notation?

//DC notation
{{dc:custom-dc:name key="value"}}

//Twig notation
{{ custom-dc.name({"key":"value"}) }}

//Error from Twig notation with the key
Unknown "access" function in "if wp-members.has-access ({"membership":"test"}) 1}

" at line 1.

I don’t think you can have it as custom-dc using a -. You would need to rename it to custom_dc or anything not using a - as it’s probably interpreting it as math. We might be able to automatically change that, but in the meantime I’ll update the docs. Have a great day.

Thank you @charlie! You’re right, it was that simple. Many thanks!

Hey @Dagaloni,

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.