Because of the restriction on character numbers in Twitter, you have to use a URL shortener when tweeting URLs. So, to help your readers tweet about your posts, you should definitely provide short URLs for all of your posts.
Here’s how to automate that task:
Open your functions.php file and paste the following code:
function getTinyUrl($url) {
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
return $tinyurl;
}
Once done, paste this in your single.php file, within the loop:
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
return $tinyurl;
}
Once done, paste this in your single.php file, within the loop:
$turl = getTinyUrl(get_permalink($post->ID));
echo 'Tiny Url for this post: '.$turl.''
?>
To see this in action, visit WpVote, and look at any post.
Source: How to: Automatically provide TinyUrls for your WordPress blog posts
0 comments:
Post a Comment