Support

Account

Forum Replies Created

  • Ok, I too fixed my own problem, but the bug is traced to something in the ACF documention (https://www.advancedcustomfields.com/resources/register-fields-via-php/ see “Add within an action“)

    So the issue is that if you are registering your ACF fields via php (which is very good for multi-sites with shared ACF fields), there is a case (and a darn rare one), in which get_field is being called before the action has ran its course, which leads the acf local fields array to only be partially populated. Therefore acf_get_local_field($key) returns false, and instead of returning the complex object, it just returns the value at the key index in the DB, which for a repeater, returns the number of items in said repeater.

    TL;DR;

    If you are enqueuing your ACF fields in an action (and exhibiting this bug), don’t add them to ‘acf/init’, add them to regular ‘init’, and then the local_field array is populated before any instance of get_field is called.

    ACF peeps? Can you please fix child theme calls to get_field, in which the parent theme is registering acf fields (on ‘acf/init’) or change your documentation to tell people to call their php includes of acf fields at wordpress’s ‘init’?

  • I’m having the same issue on a multisite instance, in which I have a child theme (which in no way modifies the core ACF functionality) which takes its ACF field definitions from the parent theme.

    1. On the child theme/multi-sites the get_field(‘handle’) returns an int (the number of items in repeater).

    2. If I try get_field(‘machine_name’), it returns NULL on the child site (and works perfectly with the parent theme).

    3. I have duplicated the EXACT same post_meta on the child, to the same effect. In fact if I migrate the DB info from child -> prod, it still works fine.

    4. This bug was introduced during the last wordpress update to 4.6.

    5. The only way I’ve been able to patch this bug is by reverting to wordpress 4.5.x

    6. In the call to get_field ‘acf_maybe_get_field’ returns no results for child, but proper results from parent.

    7. I setup a new twentysixteen theme (non multi-site) instance and was NOT able to reproduce this bug. (I will try setting up a multisite (subdomain) instance to see if it is reproducible there, but I have the feeling that it isn’t related to parent/child, other than the fact that 9 instances (multi-sites) running the parent theme are totally fine, but the 3 child themes are all exhibiting this bug).

    8. Let me know if I should open up my own bug report, but this IS the same bug in which acf calls a repeater and “ACF does not know what to do with the value so assumes it is a simple text value.”

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