pinterest not picking featured Image
i had installed pinterest for a client and after sometime the client noticed that on pining, pinterest was not picking the featured image.
i spent many hours going through the plugging code trying to find out the cause. When all had failed i noticed that the only images being picked from the page, were relatively large in size.
So i added a large size of the featured image into the post and to my surprise, it was picked by pinterest.
since this image was out of place, the only thing i had to do was to hide it.
the code below shows how i did it. you can add it to your theme files
global $post; $pcategory = get_the_category($post->ID); if($pcategory[0]->name == 'Recipe'){ $meta = get_post_custom($post->ID); $photo_id = $meta['photo'][0]; $photo = wp_get_attachment_image($photo_id, 'large', false, $attr); $photo = disect_page('src="', '" class=', $photo, array('en_offset'=>0)); $photo = str_replace('src="', '', $photo); }
there are many ways to get the path to the featured image, the code above is just one of them
<img src="<?php echo $photo?>" style="opacity:0; position:absolute; top:0; left:0; filter:alpha(opacity=0);" />
add the above html at any place in your post template. $photo contains the path to your image
the style in the img tag, ensures that the image is not visible in any browser, even older versions of Internet explorer.
you do not need this hack if you featured image is of the right size on displaying the post.if you displayed featured image is small to the extent that pinterest does not pick it, use the code above to add a hidden larger version and pinterest will pick this.