Home Forums General Issues Javascript API


Javascript API

  • Hi,

    i just read the API Docs but i was wondering how to set it up that it works?

    When i try to access the acf object from a external js file, directly in the header or in the footer i always get “acf is not defined”.

    Thanks in advance for your help.


  • When you enqueue a script you need to make sure you set the $depends argument.

    wp_enqueue_script($handle, $src, array('acf-input'), $version, true);

    it is best to enqueue your scripts on the ‘acf/admin_enqueue_scripts’ hook

    add_action('acf/admin_enqueue_scripts', 'my_acf_scripts');
    function my_acf_scripts() {
      // enqueue scripts see above
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Javascript API’ is closed to new replies.