Wordpress 提供了一个名为“the_permalink()”的函数,它在帖子循环中返回给定帖子的永久链接,您猜对了!
我正在尝试对该永久链接进行 URL 编码,并且当我执行此代码时:
<?php
print(the_permalink());
$permalink = the_permalink();
print($permalink);
print(urlencode(the_permalink()));
print(urlencode($permalink));
$url = 'http://wpmu.local/graphjam/2008/11/06/test4/';
print($url);
print(urlencode($url));
?>
它以 HTML 格式生成这些结果:
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http%3A%2F%2Fwpmu.local%2Fgraphjam%2F2008%2F11%2F06%2Ftest4%2F
我希望输出的第 2、3 和 5 行是 URL 编码的,但只有第 5 行是这样。想法?