I’m a big fan of the custom stuff you can do with Thesis. I’ve added rel author markup, specified the image Facebook uses when a post is liked, added microformatted breadcrumbs, and have even customized the text that’s used when the Tweet button is pressed.

First of all, why did I do this?

It started when I wanted #ase11 in the tweets that went out about my Affiliate Summit posts, but didn’t want that in the post title. So I first used a new Custom Field named tweet to hold the tweet text.

Thesis custom fields

Thesis custom fields

Next, I fetched this value and use it when displaying Twitter’s Tweet button:

function social_sharing() {
	if (is_single()) {
		$tweetText = get_post_meta(get_the_ID(), 'tweet', true);
		if ($tweetText == '') {
			$tweetText = get_the_title($post->ID);
		} // ends if ($tweetText == '')
	?>
	<table border="0">
		<tr>
			<td><a href="http://twitter.com/share" class="twitter-share-button" data-url="<? echo((get_permalink($post->ID))) ?>" data-text="<?= $tweetText ?>" data-count="horizontal" data-via="ericnagel">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');

This code is saved in /wp-content/themes/thesis_18/custom/custom_functions.php, and generates the following social sharing buttons (minus the breadcrumbs):

Social Sharing Buttons

Social Sharing Buttons in Thesis

When you click on the Tweet button, the text used is the custom “tweet” text, if it exists. Otherwise, the post title is used

Tweet

Custom Tweet text in Thesis

You can use this to automatically add hashtags, shorten your blog post title (see How Long Should Page Titles Be – The Social Media Factor), or add @mentions to your Tweet text.

Leave a Reply

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

*