我正在構建一個最近評論的小列表,並希望鏈接到評論被放置的實際文章。不幸的是,我找不到comment_permalink
或post_permalink
,所以我想也許會有一個get_permalink()
函數,但再次,沒有我能找到的http://codex.wordpress.org/Function_Reference/。從WordPress中的帖子ID獲取固定鏈接
單從$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>
我的意圖是將$parent->post_title
轉換爲永久。
有點沮喪,這個功能並沒有在[功能參考上市(HTTP://抄本.wordpress.org/Function_Reference /),但是謝謝你指出它確實存在!讓我想知道我還有什麼可能會失蹤。 – Aristotle 2010-07-04 01:24:49