Support

Account

Home Forums Front-end Issues get_field() error message

Helping

get_field() error message

  • Hey guys,

    iam using WordPress with the Divi theme and the Advanced Custom Fields Plugin.
    Iam trying to load the value of field ‘text_field’ from the current post.
    $value = get_field( "text_field" );

    *But iam getting this error message: Uncaught ReferenceError: get_field is not defined*

    Do i need to enqueue the ACF scripts?

    function themeslug_enqueue_style() {
        wp_enqueue_style( 'my-theme', 'style.css', false );
    }
     
    function themeslug_enqueue_script() {
        wp_enqueue_script( 'my-js', 'filename.js', false );
    }
     
    add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
    add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_script' );
    

    And where do i need to add this PHP? in Single PHP?

    Greetings Chris

  • Are you trying to call get_field() in JavaScript? This is a PHP function and will not work in JS.

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

The topic ‘get_field() error message’ is closed to new replies.