Support

Account

Home Forums Bug Reports Can't use "acf" variable in my app!

Helping

Can't use "acf" variable in my app!

    • moazam

    • December 9, 2018 at 10:26 am

    I am using Timber/Twig.

    When I create a variable “acf” http://m.pixshare.pro/2018-12-08_2322.png and use it in the twig I get fatal error: Call to a member function has_setting() on array

    I can smell bad code here: http://m.pixshare.pro/2018-12-08_2325.png Very poor approach to get acf instance! Please fix this issue.

  • It’s possible that the $context already contains an ACF object with the key acf and your code overwrites it. This will then destroy any subsequent use of $context['acf'] which Timber (or your Theme) needs.

    Try using a different key in your own code ($context['my_acf']) and see whether that helps, or just do a var_dump of $context['acf'] before the first line of code in your example, to see whether it already exists. Timber objects/context already have a lot of data in them, which you might not know already exists.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.