Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active December 19, 2015 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/5943226 to your computer and use it in GitHub Desktop.
Save braddalton/5943226 to your computer and use it in GitHub Desktop.
add_action( 'wp_enqueue_scripts', 'wpsites_load_javascript_conditionally' );
/**
* @author Brad Dalton - WP Sites
* @example http://wp.me/p1lTu0-a40
*/
function wpsites_load_javascript_conditionally() {
if ( is_page('007') ) {
wp_register_script( 'your-script', get_stylesheet_directory_uri() . '/js/your-script.js' );
wp_enqueue_script( 'your-script' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment