Last active
December 10, 2015 07:28
-
-
Save jasontucker/4401443 to your computer and use it in GitHub Desktop.
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
| <?php | |
| function twentyten_custom_scripts() { | |
| add_action('template_redirect', 'twentyten_custom_scripts'); | |
| if( is_page('Contact')) { | |
| // how is_page works http://codex.wordpress.org/Function_Reference/is_page | |
| // is_page(); | |
| // When any single Page is being displayed. | |
| // is_page(42); | |
| // When Page 42 (ID) is being displayed. | |
| // is_page('Contact'); | |
| // When the Page with a post_title of "Contact" is being displayed. | |
| // is_page('about-me'); | |
| // When the Page with a post_name (slug) of "about-me" is being displayed. | |
| // is_page(array(42,'about-me','Contact')); | |
| // Returns true when the Pages displayed is either post ID 42, or post_name "about-me", or post_title "Contact". Note: the array ability was added at Version 2.5. | |
| // register your script location, dependencies and version | |
| wp_register_script('custom_script', get_bloginfo('template_directory') . '/scripts/custom.js', array('jquery') ); | |
| // enqueue the script | |
| wp_enqueue_script( 'jquery' ); | |
| wp_enqueue_script('custom_script'); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent tutorial, bro.