Add a Pinterest Pinit Button to WordPress
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="http://pinterest.com/pin/create/button/?url=<?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="http://pinterest.com/pin/create/button/?url=<?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="http://assets.pinterest.com/js/pinit.js"></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.