In this post i will show how to put pinit button on your wordpress blog. You will get the pinit button available for website here https://pinterest.com/about/goodies/
or you can use the below peace of code.
Put this code on your template file where you want the button to appear
<a href=”http://pinterest.com/pin/create/button/?url=<?php the_permalink() ?>&media=<?php echo pinterest_image() ?>&description=<?php the_title(); ?> on <?php bloginfo(‘url’); ?>” count-layout=”horizontal”>Pin It</a>
<script type=”text/javascript” src=”http://assets.pinterest.com/js/pinit.js”></script>
Put the following code in function.php
function pinterest_image() {
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘/<img.+src=[\'"]([^\'"]+)[\'"].*>/i’, $post->post_content, $matches);
$first_img = $matches [1] [0];if(empty($first_img)){ //Defines a default image
$first_img = “/images/default.jpg”;
}
return $first_img;
}
this code featch the image that you have placed in the content area of your post
how to featch the image used in the featured area. i.e. the featured images
for this just use this code insted of the above one
<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ ); ?>
<a href=”http://pinterest.com/pin/create/button/?url=<?php the_permalink() ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?> on <?php bloginfo(‘url’); ?>” count-layout=”none”>Pin It</a>