CREATE TINY URL FOR POSTS IN WORDPRESS


/ Published in: PHP
Save to your folder(s)

Creates a tiny url for posting on twitter etc.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.