how would I include a js file with tags into wordpress?

First you should use the wp_enqueue_scripts to load your scripts.

add_action( 'wp_enqueue_scripts' , 'javascript_file-exmp' );

Second, be sure to both register and then enqueue your script

Register:

wp_register_script( 'links', plugins_url( 'test.js', __FILE__ ), array( 'jquery' ), '1.0', true  );

1.0 is the version, used mainly to avoid caching on when you update it.

true controls whether the script can be called from the bottom of the page rather than in the <head> tag.

Enqueue

wp_enqueue_script( 'links' );

Lastly, as suggested above you should really separate your HTML from your javascript.

Leave a Comment