Posted By

daprela on 06/30/14


Tagged

wordpress tinyurl


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jakkrith


Add a Tinyurl link


 / Published in: PHP
 

Generate The Tiny URL to add to any post

  1. /* Generate The Tiny URL - Add to your functions.php file */
  2.  
  3. function getTinyUrl($url) {
  4. $gettiny = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
  5. return $gettiny;
  6. }
  7.  
  8. /* Call The Tiny URL - Add to your single.php file within the loop */
  9.  
  10. <?php
  11. $tiny = getTinyUrl(get_permalink($post->ID));
  12. echo 'Tiny Url: '.$tiny.''
  13. ?>

Report this snippet  

You need to login to post a comment.