Skip to content

Instantly share code, notes, and snippets.

@jasontucker
Last active December 10, 2015 07:28
Show Gist options
  • Select an option

  • Save jasontucker/4401443 to your computer and use it in GitHub Desktop.

Select an option

Save jasontucker/4401443 to your computer and use it in GitHub Desktop.
<?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');
}
}
?>
@mrxinu
Copy link
Copy Markdown

mrxinu commented Dec 28, 2012

Excellent tutorial, bro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment