Ari*_*tle 1 wordpress post permalinks
我正在构建一个最近评论的小列表,并希望链接到评论所放置的实际帖子.不幸的是,没有comment_permalink
或post_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
转换为永久链接.
我想也许会有一个get_permalink()函数,但是我再也找不到了.
http://codex.wordpress.org/Function_Reference/get_permalink
我也建议使用它 get_page_link()
get_permalink()
检查帖子类型并返回相应函数的结果;
get_page_link()
get_attachment_link()
get_post_permalink()
归档时间: |
|
查看次数: |
8193 次 |
最近记录: |