从Wordpress 3中的帖子ID获取永久链接

Ari*_*tle 1 wordpress post permalinks

我正在构建一个最近评论的小列表,并希望链接到评论所放置的实际帖子.不幸的是,没有comment_permalinkpost_permalink我能找到,所以我想也许会有一个get_permalink()功能,但是再一次,我找不到http://codex.wordpress.org/Function_Reference/.

$post->ID单独的角度来看,我该如何找到该特定帖子的永久链接?并不是说它是完全必要的,但这是我到目前为止所拥有的:

<?php $comments = get_comments( array( 'status'=>'approve', 'number'=>5 ) ); ?>
<p class="recently-posted-comments">Recent Comments</p>
<ul>
<?php foreach ($comments as $comment): $parent = get_post($comment->comment_post_ID); ?>
  <li><?php print $comment->comment_author; ?> 
      on <?php print $parent->post_title; ?></li>
<?php endforeach; ?>
</ul>
Run Code Online (Sandbox Code Playgroud)

我的意图是将其$parent->post_title转换为永久链接.

The*_*dic 5

我想也许会有一个get_permalink()函数,但是我再也找不到了.

http://codex.wordpress.org/Function_Reference/get_permalink

我也建议使用它 get_page_link()

get_permalink() 检查帖子类型并返回相应函数的结果;

  • 页面使用 get_page_link()
  • 附件使用 get_attachment_link()
  • 自定义帖子类型使用 get_post_permalink()