working pop-up pinit button

I had a weird problem with Pin It button present on my floating share bar. It came to notice when I didn’t find any pins in my profile. Pin button use to give pop-up and it was all ok. However, after pinning it nothing was getting posted. I dug it up and change many buttons from official page. Alas! All in vain.

I came to know from many sources that there is a problem with ‘href’. Official Pin Button works properly only when there is a valid static URL. Now, WordPress and PHP are all about dynamic pages. So, I tried using permalink also;

<?php the_permalink(); ?>

It didn’t work. Second problem was with post titles and images. Pulling titles and images from dynamic URL is something that official code is not designed for. After so much Googling and code testing, I got which can be made to work. Idea came from a guy Ari Krzyzek.

This Pin button pulls post title automatically and also gives you an option to select images found in an article and also from related to it (Check below Screenshot). I am using the same for my manual floating social share bar.

working pop-up pinit button

Put the following code into a PHP file (single post or Main Index) of your theme;

<div class="sf-pinterest">
<a href='javascript:void((function()%7Bvar%20e=document.createElement(&apos;script&apos;);e.setAttribute(&apos;type&apos;,&apos;text/javascript&apos;);e.setAttribute(&apos;charset&apos;,&apos;UTF-8&apos;);e.setAttribute(&apos;src&apos;,&apos;http://assets.pinterest.com/js/pinmarklet.js?r=&apos;+Math.random()*99999999);document.body.appendChild(e)%7D)());'><img src='http://passets-cdn.pinterest.com/images/about/buttons/big-p-button.png' width='50' height='50' alt='Pin It'/></a>
</div>

I used DIV container so that you can also use styling in your theme’s stylesheet.css. You can modify the margins, heights  and boundaries, etc.

}
.sf-pinterest {
              YOUR STYLING CODES;
}

I hope this works for you. If you want a full working floating share bar with pre-included Facebook, Google+, Twitter, etc in just two steps then please refer this article.

Enjoy!

By Mrinal Buddekar

Data Manager and a technology enthusiast! Mrinal Buddekar is Pune based blogger who loves building server, websites, technology, and affiliate blogging.

Hey there!

Help us reach out to awesome people lie you out there. We publish Tech and WordPress, Deals, and Reviews. WE DON'T SPAM!

Your Information will never be shared with any third party