Skip to content

Instantly share code, notes, and snippets.

@thetwopct
Created March 4, 2019 09:02
Show Gist options
  • Save thetwopct/127bb7b5ae25d1f8898b6e99970928a5 to your computer and use it in GitHub Desktop.
Save thetwopct/127bb7b5ae25d1f8898b6e99970928a5 to your computer and use it in GitHub Desktop.
Add javascript file per page for WordPress
function load_js_assets() {
if( is_page( ID ) ) {
wp_enqueue_script('my-js', 'PATH TO JS FILE', array('jquery'), '', false);
}
}
add_action('wp_enqueue_scripts', 'load_js_assets');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment