Wp pinterest integration in a blog posts

August 1, 2012 | | Blog |

The pinterest requires a script which needs to be added to the footer. So in wp we can either use a action to call in footer or use the script tag directly in footer.php

This will initialize the pinterest. To link any featured image in a post or page paste the below function in functions.php

function pinterest_image() {
global $post, $posts;

$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$url = $thumb['0'];
return $url;

}

We can modify the size of image by changing ‘full’ to ‘thumbnail’ or custom size etc

Inside the blog posts page under loop add the below code

<a href="http://pinterest.com/pin/create/button/?url=&media=&description= on " class="pin-it-button" count-layout="horizontal">Pin It

This would create a pin-it button under each post.