James Bachini

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

Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.



, ,