Support

Account

Home Forums General Issues How to use acf.getField()

Unread

How to use acf.getField()

  • Hi All,

    I’ve just started using ACF and very new to JS – I’m trying to use the acf.getField() function to return the value in a field within a post.

    Here is the code i have:

    <script>
    (function($, undefined){
      var myimage1 = acf.getField('image1');
      //test the variable loaded
      document.write(myimage1);
    
      document.getElementById("ImageURL").src = myimage1;
    })(jQuery);
    </script>

    When this loads its outputs [object Object]

    I suspect i need to reference a specific value? i’ve seen references to acf.getField(‘image1’).val() – but when i try this i get nothing back.

    Anyone able to give me some direction on the correct calli need to make to get the value passed back? for reference this field is a URL.

    Any help would be appreciated.

    Cheeer

Viewing 1 post (of 1 total)

The topic ‘How to use acf.getField()’ is closed to new replies.