We design and develop websites, digital experiences, and software solutions for growing businesses.
URL shortening is an important part when you play blogs with social media. You can get short url in two ways first is a third party services like tinyurl.com and other is using of a WordPress Plugin. Here we are going to make short urls by first method, that is using tinyurl.com. For doing this place below codes on appropriate places of your WordPress theme as described below.
<?php function getTinyUrl($url) { $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); return $tinyurl; } ?> |
<?php $turl = getTinyUrl(get_permalink($post->ID)); echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>' ?> |