Created
May 15, 2012 14:27
-
-
Save cdharrison/2702170 to your computer and use it in GitHub Desktop.
Set Default Pinterest Share Image based on Featured Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( has_post_thumbnail() ) : | |
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 720,405 ), false, '' ); | |
?> | |
<a href="http://pinterest.com/pin/create/button/?media=<?php echo $src[0]; ?>&url=<?php the_permalink() ?>" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a> | |
<?php else : ?> | |
<a href="http://pinterest.com/pin/create/button/?media=http://example.com/example.png&url=<?php the_permalink() ?>" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment