Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add Pinterest pin-it button to Woocommerce single product page
<?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
You can’t perform that action at this time.