Custom Facebook Share and Twitter Tweet Buttons as WordPress Widget

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=”<?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=”;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.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *