Custom Facebook Share and Twitter Tweet Buttons as WordPress Widget

0
264

The following is the php code to make your own dynamic Facebook share and Twitter tweet buttons. Just place the images in the root directory and install the Samsarin PHP widget. Copy this code into a Samsarin Php widget and drag it to your sidebar.

<a target=”_blank” href=”http://www.facebook.com/sharer.php?u=<?php echo “http://” . $_SERVER[‘HTTP_HOST’]  . $_SERVER[‘REQUEST_URI’]; ?>”><img src=”/share-facebook.png” alt=”Share on Facebook” border=”0″ /></a>
<br />
<a title=”Share on Twitter” href=”http://twitter.com/share?_=1292093673417&amp;count=horizontal&amp;original_referer=<?php echo “http://” . $_SERVER[‘HTTP_HOST’]  . $_SERVER[‘REQUEST_URI’]; ?>&amp;text=<?php echo urlencode(get_the_title(get_the_ID())); ?>&amp;url=<?php echo “http://” . $_SERVER[‘HTTP_HOST’]  . $_SERVER[‘REQUEST_URI’]; ?>” target=”_blank”><img src=”/tweet-twitter.png” alt=”Share on Twitter” border=”0″ /></a>

An example of how we have implimented this on a wordpress blog can be seen at: DIY advice

Installing a facebook and twitter wordpress widget

I hope this is of use to all the wordpress coders out there. We really can’t stress enough how important social signals are going to be in the future of search.

LEAVE A REPLY

Please enter your comment!
Please enter your name here