Add Pinterest button on Woocommerce Product page manually

woo-plus-pinterestWe all know adding Social media icons on wordpress is easy as 1,2,3. There are lots of social media plugins we can find in WordPress repository but what if sometimes we don’t want to use a WordPress plugin just to add a social media button like Pinterest.

In Woocommerce we need to hook a function so we can customize and add pinterest on every product page.

To do that, I have a simple code here that I will share so you can use to add in your functions.php.

1. First add this in your header.php or footer.php

 

2. Then add this in your functions.php

 

I will explain the above code. after adding the script code for Pinterest API, Now we will use a hook type called add_action. You can found add_action on WordPress Codex. Now we will add the woocommerce_share hook. We will create a function, I name my function pinshare(). Now that I have a function, I will get the featured image of the post. We need these so when it will be use on pinterest image. Creating the icon manually using css, custom pinterest icon.

I hope this post will help a lot.