I don’t think the Official Facebook button is well enough. There is official Plugin also, but for advance developer they need control, we need flexibility to control the size and colour. While redesigning TheTechJournal.com I found FBShare.me is best to use with a bit easy tweaking for WordPress. Check The Code Below
In any place where you want to show the Share button, like index.php or single.php use this
<script>var fbShare = {
url: ‘<?php the_permalink() ?>’,
size: ‘large’,
badge_text: ‘C0C0C0’,
badge_color: ‘336699’,
google_analytics: ‘true’
}</script>
<script src=”http://widgets.fbshare.me/files/fbshare.js”>
For more control here is advance option
- size – The size of the button: ‘large’ OR ‘small’ (if not specified, defaults to ‘large’)
- url – The URL of the page you want shared on Facebook (if not specified, defaults to that of the page on which the button is displayed)
- title – The name of the page you want shared on Facebook (if not specified, defaults to that of the page on which the button is displayed)
- google_analytics – If no awesm_api_key specified, sets whether fbshare.me links have Google Analytics parameters added: true OR false (if not specified, defaults to false)
- awesm_api_key – For existing awe.sm customers only (if not specified, will use fbshare.me links)
- badge_text – Change the color of the text in the badge for the large button (use standard CSS RGB hex codes, *do not* include a leading #)
- badge_color – Change the color of the badge background for the large button (use standard CSS RGB hex codes, *do not* include a leading #)
How it Works
awe.sm is a campaign tracking platform for social media that generates a unique link every time someone shares content through our system. Since each link is encoded with metadata about the share action it represents, including the channel for which it’s destined (e.g. Twitter or Facebook or LinkedIn, etc), it’s very easy to find out how many times a given URL has been shared to a given channel (and how many clicks those shares have generated).
This particular button is built on top of our Aggregate Data API, which can be used by any developer to retrieve anonymized aggregate data about the shares tracked through our system. We built it to showcase the power of our platform and the ease of developing on our APIs (this was a weekend project).
To learn more about awe.sm, check out our original announcement. And apply to the awe.sm developers group to get full access to our API documentation.
All Thanks goes to FBShare.me, i just make it useful for WP. And i am sure from now on everybody looking for this code will find this post in top of Google Search, as Google Loves me a lot.
Leave a Reply