Skip to content

Instantly share code, notes, and snippets.

@mattmcgiv
Created March 13, 2015 12:23
Show Gist options
  • Save mattmcgiv/c2a0ad005fa66fe0f20e to your computer and use it in GitHub Desktop.
Save mattmcgiv/c2a0ad005fa66fe0f20e to your computer and use it in GitHub Desktop.
Add JavaScript to a specific WordPress page or post
function mm_js_in_wp_head($pid){
global $post;
// only for post Id = 720
$mm_id_of_page="720";
if($post->ID==$mm_id_of_page){
echo "<script>alert('hello world');</script>";
}
}
add_action( 'wp_head', 'mm_js_in_wp_head' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment