How to add php within jquery
I see no reason for you to use PHP in your JavaScript file. Enqueue your script properly using the wp_enqueue_scripts hook and then use the wp_localize_script()function to pass your data to your JavaScript code. <?php function wpa67325_enqueue_scripts() { wp_enqueue_script( ‘some_handle’, ‘filename.js’, false ); $translation_array = array( ‘some_string’ => __( ‘Some string to translate’ ), ‘a_value’ … Read more