Last active
August 29, 2015 14:00
-
-
Save Willem-Siebe/11351787 to your computer and use it in GitHub Desktop.
Loads the Pinterest JavaScript asynchronously. I add this to my WordPress website with wp_head, but you can copy and paste this snippet anywhere on your page. You only need to load this script once per page, no matter how many buttons or widgets you use. See: https://developers.pinterest.com/pin_it/. I also added a line to set the data-pin-hover…
This file contains 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
// Add Pinterest Javascript to your website, see https://gist.github.com/Willem-Siebe/11351787. | |
function wsis_add_pinterest_script() { | |
?> | |
<script type="text/javascript"> | |
(function(d){ | |
var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT'); | |
p.type = 'text/javascript'; | |
p.async = true; | |
p.setAttribute('data-pin-hover', true); | |
p.src = '//assets.pinterest.com/js/pinit.js'; | |
f.parentNode.insertBefore(p, f); | |
}(document)); | |
</script> | |
<?php | |
} | |
add_action( 'wp_head', 'wsis_add_pinterest_script' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On 12-04-2014 I discovered that when you are logged in with WordPress, there is a offset for the pin it button.