Home Forums General Issues Using a the_field in Javascript Reply To: Using a the_field in Javascript

  • this looks like a script that is included using a script tag with an url like.

    <script src="path/to/script">

    PHP to output anything to do with WP cannot be added to such a script. To add directly to this you would need to output the script inside of a template file something like

       // code of script here.

    So that it is part of the HTML page and not a separate .js file

    To add variable values to the type of script you are using it must be registered, localized and enqueued using WP hooks and actions