Using get_field
does not work in previews (i.e. do Preview > Open in new tab).
I have located the cause of the issue, and explained my findings in detail in this reply:
https://support.advancedcustomfields.com/forums/topic/custom-fields-on-post-preview/#post-150273
This doesn’t happen every time though. I’ve found that the first time you open a preview, the bug is there. But if you copy the preview URL and paste it into a new tab, then refresh that tab, the bug is no longer present. But if you go back to the post and click the “Open in a new tab” preview link again, the bug occurs.
Additionally — and this is a minor aside to the bug above — there is also a related issue of the filter acf/validate_post_id
being used internally to apply code that only relates to previews (and it’s within this code that the problem lies). So I think this code, if kept, should be moved to a dedicated method/filter.
See also:
This reply has been marked as private.