Skip to content

Instantly share code, notes, and snippets.

@frankschrijvers
Created April 25, 2016 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankschrijvers/a8cf74c2564fbe8ee1109eebb0d128af to your computer and use it in GitHub Desktop.
Save frankschrijvers/a8cf74c2564fbe8ee1109eebb0d128af to your computer and use it in GitHub Desktop.
Add Pinterest pin-it button to woocommerve single product page
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add Pinterest pin-it button to woocommerve 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()). '"><img src="' . $pinterestbutton . '" /></a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment