Hi,
I want to use ACF Javascript API at my frontpage but when I try to use acf on javascript it’s getting undefined. How I can do that?
I was reading about and it seems to be only enqueued at admin pages right? What if I want to use acf javascript API like at my home page?
Also would it be insecure doing that because the variable is global?
ACF’s JS is loaded on the front end of the site when using acf_form()
and calling acf_form_head()
. https://www.advancedcustomfields.com/resources/acf_form/
Sorry @hube2 you probably got it wrong.. I don’t want to bring the acf_form to my frontend. I just want to use acf at my frontend.
I want to create a script like that:
var field = acf.getField(‘field_123’);
If I get what your after… you cannot get fields for a current post using ACF js unless the actual ACF fields are displayed on the page. As far as I know the acf scripts will not perform AJAX to get the content. This is only possible using PHP at the moment.
Got it @hube2 many thanks.