Add a Pinterest Pinit Button to WordPress

Pinterest Logo

Pinterest is on quite an upswing in popularity… so much so that other social sharing sites are starting to lose some ground. I believe the advantage of Pinterest is that it’s a visual medium that’s well laid out to share information. While other sites have boring lists, the mozaic that Pinterest generates is simple to scroll through to find what captures your interest.

With that in mind, social sharing sites are fantastic traffic generators, so why not make it easy to share your content? Today, we’ve added a Pinterest Pinit button to our WordPress theme. It was pretty simple to do… and we even incorporated pulling the featured thumbnail button as the image URL.

If you would like a Featured Image to display, here’s theme code to add a Pinit button to your theme within the Loop:

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

If you don’t want to specify the image, here’s the alternative code:

<a href="<?php the_permalink(); ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="horizontal">Pin It</a>

Also – be sure to add the Pinterest script to your footer.php

<script type="text/javascript" src=""></script>

For additional information on generating a Pinit button or to take a look at their other apps and features, take a look at the Pinterest goodies page. The folks at Buffer have also described How To Add The Pinterest Pin It Button To Your Blog And Let People Pin Posts With Pictures using the latest version of the Digg Digg plugin.


  1. 1
  2. 3
  3. 5

    ID), ‘thumbnail’ ); echo $thumb[‘0’]; ?>
    I owe you a whole heap of gratitude for this little gem, sir.
    Allowed me to fix up the ShareThis code for use on wordpress (ShareThis is nice but it sure needs a lot of tweaking before it’s useful).

    In case anyone happens upon this in the same situation as me:

    < span class='st_pinterest_hcount' displayText='Pinterest' st_img='ID), ‘thumbnail’ ); echo $thumb[‘0′]; ?>&description=’>

    Add any other bits you need like st_title st_url st_blahblahblah
    I hope this comment doesn’t get parsed…
    edit: goddammit it does get parsed, that’s pretty daft. Added a few spaces and bits so it displays.

  4. 6

    Hey actually I just found, 1 minute later, that you can do it this way:

    (inside head tags)
    <  meta property="og:image" content="ID), ‘thumbnail’ ); echo $thumb[‘0’]; ?>” />

    pinterest then pulls the image from this ‘opengraph’ malarkey. Spiffy!

  5. 9
    • 10

      @twitter-61936398:disqus You must have count-layout=”horizontal” for the counter to appear to the right.  If you have that correct and you have the layout correct, you probably just have to wait for pinterest to actually update the count.  I don’t believe they display it when it’s zero.

      • 11

        Hi Douglas, you’re absolutely right!!! 🙂 If you have no pins and so the counter is at zero, it won’t show up beside the “Pin it” button. I’ve set a test pin to check it, and when the counter was updated to “1” it appeared beside its button. Thank you for your hint! 🙂

        Maybe this feature should be described right in the article.

  6. 13

    My experience with pinterest:

    I’ve used pinterest to optimize my site’s ranking and the outcome was good, it has improved from page 6 to 4rd spot of 1st page within 3 weeks.

    I found that the seller named “pinterest”, which ranked first when you search “pinterest” at Fiverr, has produced the best results on my websites. The seller pins my site with 75 different people, not sure how he did this, but it has improve my SERP’s ranking. I’ve tried 5 other sellers who offer pinterest gigs on Fiverr but they can’t improve my site’s ranking. I don’t know why.

    After using pinterest for SEO for quite some time, I’ve discovered some of its benefits:
    – Google loves social media signal.
    – Each pin is considered as 3 inbound links.
    – Links and images from pinterest are dofollow.
    – Remember to ping the links of the pins to get indexed by Google.

  7. 14

    As blogger I’m using pinterest to optimize my site’s ranking and the outcome was good, it has improved my pages. Thank you for this informative post! 🙂

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.