PHP 为WORDPRESS中的帖子创建小小的URL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 为WORDPRESS中的帖子创建小小的URL相关的知识,希望对你有一定的参考价值。

//place in functions.php in theme folder
<?php function getTinyUrl($url) { $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); return $tinyurl; } ?>
 
//call the function on the page
<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>

以上是关于PHP 为WORDPRESS中的帖子创建小小的URL的主要内容,如果未能解决你的问题,请参考以下文章

WordPress中具有自定义帖子类型的单个页面的层次结构

添加第二个 Wordpress 循环,显示 single.php 中的最新帖子

为啥我不能在 Wordpress 中创建新帖子?警告:从第 716 行 /public_html/wp-admin/includes/post.php 中的空值创建默认对象

为自定义帖子类型创建存档:wordpress

php 创建 zip 文件(来自 post 附件 wordpress)

如何根据wordpress中的当前帖子自动选择一个值?