Last active
December 16, 2015 12:59
-
-
Save alwerner/5438300 to your computer and use it in GitHub Desktop.
Wordpress conditional script loading in functions.php. Source: http://www.organizedthemes.com/loading-scripts-conditionally/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( !is_admin()){ | |
wp_register_script('thescript', get_template_directory_uri() . '/path/to/thescript.js', array('jquery'), '1.2.3', true ); | |
} | |
function conditional_scripts() { | |
if( !is_admin() && is_page('somepage') ){ | |
wp_enqueue_script('thescript'); | |
} | |
} | |
add_action('wp_enqueue_scripts', 'conditional_scripts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment