I have some Pinterest code to show a Pin it button on my wordpress posts but it only grabs the post thumbnail. What I want is to grab the first post content image and only grab the thumbnail if there are no images in the post!??
Have tried tons of examples but nothing works.
<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>
You may try this, just paste following function in your
functions.php
Before your
Pinterest
code get the imageThen in your
Pinterest
linkmedia=<?php echo $thumb; ?>