Add A Pinterest Button To The Sharebar WordPress Plugin
by Chaunce Dolan on Friday, March 30th, 2012
We were looking to add the Pinterest button to our site’s Sharebar so that users could pin our content on their boards. After visiting Pinterest’s Goodies Page we saw that they have code that you can add to any page or plugin. However, the provided code doesn’t work properly.
When you click the button to pin that page, the window is supposed to scan images from the page for you to select from. Unfortunately, the image selector is blank thus not allowing you to pin anything.
After doing quite a bit of digging and testing other fan-made solutions, I came across a solution at Pinwire that works really well. It is a modified version of the bookmarklet that Pinterest also offers. It also includes the Pinterest social media share button image, and works really well too.
The only downside to using this method over the one that pinterest provides, is that it doesn’t display the number of pins that page has similar to the way other social media share buttons do. It is a small trade off to have something that actually works though, seeing as how the whole idea behind Pinterest is being able to pin an image.
How to Add Pinterest Button to Sharebar
- Go to Settings in WordPress and select Sharebar
- Click “Add New Button”
- Name your button “Pinterest”
- Input the desired position of the button
- Copy the code below and paste in the “Big Button” field
- Click “Add Button”
- Enable the button by checking the box to the left and click “Update” at the bottom
- You may want to reorganize your buttons also at this point by clicking the arrows
Pinterest Button Code
<a href="javascript:javascript:void((function(){var e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)})());" title="Pin It!"><img src="http://passets-cdn.pinterest.com/images/pinit_preview_none.png"></a>

Thanks..it works
Thanks! This is working great on my site, but is there any way to display the counter using this method?
I haven’t been able to come up with a working version like that yet.
Thanks so much for the code. I have been looking for a code that worked and this did the trick in the sharebar. I appreciate the guide and so does GameNTrain!
You are welcome. Glad it worked out for you
Thanks for sharing this. I’ve been looking for the right code to add Pinterest in my blog post. then I got the right one. awesome!
Thanks for the code! It works great! And easy! Thanks!
Glad to hear it worked out for you
This isn’t working for me.Upon clicking, nothing happens
When the button is clicked, it opens a popup window. Your browser may be blocking that popup
Hi Chaunce,
Great, thanks so much for sharing this. It worked just as you described.
Wendy
Absolutely brilliant, thanks!
Thanks for letting us know about this I really appreciate it.
It worked first time. Woo hoo !!
i’d make one small adjustment. for sites that are responsive, add the width and height to the image. otherwise the “pin it” image will stretch to the width of the contents:
[img style="width:49px; height:25px;" src="http://passets-cdn.pinterest.com/images/pinit_preview_none.png" /]
Thank you! That was very easy and worked without any tweaking.
Thanks for making it easy for us newbs Chaunce, works perfectly.
For some reason, that javascript doesn’t work for me. I added it to my site, if you go to the site you can see the button, but clicking the button does nothing. Not sure why. Any ideas?
Yeah, I see what you mean. It is the same script that we us and many others have used. I wonder if you have another script that may be conflicting with it. I have also heard some people say it wasn’t working one day, then all of a sudden, it was. Maybe give it a day or two and see if it rights itself.
Hi,
I can’t get the Pinterest part to work when it’s not on my homepage. For example, if it’s on a specific post, the “Pin It” doesn’t work.
Please help
Thanks!
Is it still not working for you? I noticed in some instances that the code would take a while to start working (no idea why).
tnx, amazing stuff! was searching for this a long time! IS there a way to show number of pins?