I am trying to use a custom "Pin It" button for Pinterest that goes on each post and which pulls from the featured image of that post.
So far I have this script which successfully pulls the feature image of the post, as well as shows it in a pop-up window:
<script type="text/javascript">
(function() {
window.PinIt = window.PinIt || { loaded:false };
if (window.PinIt.loaded) return;
window.PinIt.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent("onload", async_load);
else
window.addEventListener("load", async_load, false);
})();
</script>
And here is the code I use in my single.php:
<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>">Pin It</a>
I can't figure out how to change the "Pin It" button to my own custom button; every time I try my button gets overridden.
I hope this explains it well enough. I'm still very new to php and javascript. Thank you for any help you can provide.