Performancing Metrics

How to Add the Pinterest Pin It Button To Your WordPress Blog

Pinterest is all the rage these days. People just love pinning up pictures and graphics like there is no tomorrow. If you have a WordPress blog, then you can add the Pin It button to your blog pretty quickly. Here is what you need to do:

Copy and paste the following code right before the closing </body> tag in your theme file footer.php:

<script type="text/javascript">
(function() {
window.PinMe = window.PinIt || { loaded:false };
if (window.PinMe.loaded) return;
window.PinMe.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = "";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
if (window.attachEvent)
window.attachEvent("onload", async_load);
window.addEventListener("load", async_load, false);

Pin It Button

Once you have done that, make sure you update the footer.php file, or reupload it if you are editing the footer.php file any other way. You want the new version in place. Then, paste the following code into your single.php theme file wherever you deem appropriate. You might have to experiment a bit to realize the best possible location of the button for your blog.

<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="vertical">Pin It</a>

Pin It Button 2

Now, here is what this button code does: Wherever you place the button code in single.php, on each post page there will be a Pin It Button. Once clicked, the code will pop open a little Pinterest window, and it will use the featured image of that post as the submission pic. Similar to this:

Pin It 3

There you go! Play around with it a little and you will find what works best for your blog. If you aren’t seeing any image in the pop up then your post doesn’t have a featured image specified for it. For best practices, always make sure you classify one image of each post as a featured image, because many plugins and buttons use the featured image slot.

Categories: Blogger Tools, Blogging: How To, General
Tags: , , , ,

This post was written by . You can visit the for a short bio, more posts, and other information about the author.

Comment with Your Facebook Account


  1. Kat ) says: 2/20/2012

    You are the damn savious of the pinterest people!


  2. Kat ) says: 2/20/2012

    You are the damn saviour of the pinterest people! (you can delete that last typo comment). Thanks again! This saved me bunches of time trying to figure out how to write this out.


  3. samsung 1080p hdtv says: 2/28/2012

    I’m very impressed by how you have represented the information in this article. It’s apparent that you’ve done some extensive research. Thanks for this input.


  4. The Snacker ) says: 2/29/2012

    Hmm, the image doesn’t show when I add this. Only the anchor text.


  5. Hawaii Wedding Photographers says: 4/16/2012

    You managed to really load this article up with information that is of real value. I appreciate good writing, and this is really good. I agree with the points you make here. Very nice work.


  6. Hawaii Wedding Photography says: 4/20/2012

    Many ideas have been written with standard views from what you wrote, but never have I seen such conviction and determination in the writing such a positive and pleasing document.


  7. Dulcelina says: 4/25/2012

    thanks! great web site. thank you for the information this site is amazing. very well developed with great information.


  8. Alex ) says: 9/30/2012

    is there any way to add pin button in thesis theme without plugin?


  9. Elton Neufville says: 6/8/2013

    Wow, awesome blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is wonderful, let alone the content!. Thanks For Your article about How to Add the Pinterest Pin It Button To Your WordPress Blog | BloggingPro .


Performancing Metrics
EatonWeb Portal