/ Published in: PHP

Creates a tiny url for posting on twitter etc.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//place in functions.php in theme folder <?php function getTinyUrl($url) { $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); return $tinyurl; } ?> //call the function on the page <a href="http://twitter.com/home?status=Currently reading <?php the_title(); ?> : <?php $turl = getTinyUrl(get_permalink($post->ID)); echo $turl ?>" title="Tweet this">Twitter link</a>
Comments
