Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created February 21, 2012 20:55
Show Gist options
  • Save danielbachhuber/1878875 to your computer and use it in GitHub Desktop.
Save danielbachhuber/1878875 to your computer and use it in GitHub Desktop.
Conditionally load resources based on page slug
<?php
add_action( 'wp_enqueue_scripts', 'db_conditionally_enqueue_scripts' );
function db_conditionally_enqueue_scripts() {
// Don't do anything if it's not the proper page slug
if ( !is_page( 'my-page-slug' ) )
return;
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jwplayer','
http://video.ted.com/assets/player/js/jwplayer_5_7.js' );
wp_enqueue_script( 'db-tabs-js', get_template_directory_uri() . '/js/tabs.js', array( 'jquery' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment