Last active
April 25, 2016 10:32
-
-
Save frankschrijvers/e701d0a0c4ebd5804232fde0f94daa88 to your computer and use it in GitHub Desktop.
Add Pinterest pin-it button to Woocommerce single product page
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
//* Add Pinterest pin-it button to Woocommerce single product page | |
add_action('woocommerce_share', 'wps_pinterest_share' ); | |
function wps_pinterest_share(){ | |
global $post; | |
$pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); | |
$pinterestbutton = '//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png'; | |
echo '<a data-pin-do="buttonPin" href="//www.pinterest.com/pin/create/button/?url='.get_permalink().'&media='. $pinterestimage[0].'&description=' .urlencode(get_the_title()). '" data-pin-media="' . $pinterestimage[0] . '"><img src="' . $pinterestbutton . '" /></a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment