php wordpress

URL curta no WordPress

As URLs curtas possuem muitas utilizações por aí, principalmente em microblogs como o Twitter.

<?php

function getShortUrl($url) {
  $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
  return $tinyurl;
}

?>

Use a função acima no arquivo functions.php do seu tema. Para exibir o link, crie a seguinte linha no arquivo do post – single.php:

<?php echo '<a href="'.getShortUrl(get_permalink($post->ID)).'">short url'; ?>
Avatar photo If you like my content, follow me on Twitter and GitHub TwitterTweet

Interactions

Webmentions

Comments

comments powered by Disqus