Posted By

vagrantradio on 02/16/10


Tagged

url link wordpress function permalink tiny


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

laurentzziu
blitz


CREATE TINY URL FOR POSTS IN WORDPRESS


 / Published in: PHP
 

Creates a tiny url for posting on twitter etc.

  1. //place in functions.php in theme folder
  2. <?php function getTinyUrl($url) { $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); return $tinyurl; } ?>
  3.  
  4. //call the function on the page
  5. <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>

Report this snippet  

You need to login to post a comment.