Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 '短縮URL: <a href="'.$turl.'">'.$turl.'</a>' | |
?> |
Screen shot
Note
Description | パーマリンクをtinyurl.comのAPIで短縮URLに変換してテーマファイル内に設置する |
---|---|
WordPress Ver. | 3.3.1 |
Via | Automatically provide tinyurls for your WordPress blog posts |