众所周知,函数the_permalink 在循环中回显当前帖子的URL,而函数get_permalink 使用返回特定帖子的永久链接$post_id, 但是get_permalink 有$leavename 这允许返回帖子的URL结构,以最终(例如)获得如下URLhttp://localhost/%postname%/. 那么,我什么时候可能需要这样的输出?
请注意输出:
<?php
$x= get_permalink($post_id, true);
echo $x;
//output
//http://localhost/%postname%/
?>
如果我把
$leavename 到
false 我将在URL中已经有帖子名称。再说一遍,是什么让我把它变成
true