Jun.01

Adding Google’s +1 To Your Thesis Themed Site


Within /wp-content/themes/thesis_18/custom edit custom_functions.php, and add:

function social_sharing() {
	if (is_single()) {
	?>
	<table border="0">
		<tr>
			<td><a href="http://twitter.com/share" class="twitter-share-button" data-url="<? echo((get_permalink($post->ID))) ?>" data-text="<? echo((get_the_title($post->ID))) ?>" data-count="horizontal" data-via="YOURUSERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></td>
			<td><iframe src="http://www.facebook.com/plugins/like.php?href=<? echo(urlencode(get_permalink($post->ID))) ?>&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=like&amp;font=trebuchet+ms&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></td>
			<td><g:plusone size="medium"></g:plusone></td>
			<td><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&r=<? echo(urlencode(get_permalink($post->ID))) ?>"></script></td>
		</tr>
	</table>
	<?php
	} // ends if (is_single())
} // ends function social_sharing()

add_action('thesis_hook_before_post', 'social_sharing');

Make sure you change YOURUSERNAME to your Twitter username

Then in Thesis Site Options, the Stat and Tracking Scripts field, add

<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>

Make sure you Specify The Thumbnail Image When Sharing A Link On Facebook From Your Thesis Site to make Facebook’s Like button work nicely.

Resources
Share this Story:
  • facebook
  • twitter
  • gplus

Comments(5)

  1. James Seligman
    2013 days ago

    Work Perfectly! I was getting tired of the SexyBookmarks plugin

  2. Logan Thompson
    1973 days ago

    Nice, other than you use a table. CSS is your friend Eric.

    • Eric Nagel
      1973 days ago

      Yeah, maybe some day I’ll fix that. I’m a programmer, not a coder. BIG difference.

      • Logan Thompson
        1972 days ago

        Haha, I know. I’m a coder not a programmer. Huge difference.

  3. Trackback: E-Mail A Post WordPress Function

Leave a comment

Comment