【发布时间】:2016-01-09 10:10:29
【问题描述】:
我在从其他作者的帖子中获取我的所有 cmets 并在我自己的帖子中显示时遇到问题。 我做了一个循环来捕获其他作者的所有帖子并成功显示在我自己的帖子中。在每篇文章的下方,我想显示我所有的 cmets 并仅针对我的 cmets 进行过滤,但结果显示其他作者的所有 cmets。
这是我用来在循环单个模板中捕获所有 cmets 的代码:
/** This is outside loop to capture my own author email not from within loop which is from other author's post **/
$MyEmail = the_author_email();
/** This is inside loop **/
<?php
$args = array(
'post_id' => $post->ID,
'author_email' => $MyEmail,
/** When I used comment_id it will displays all comments even I used my comment_id taken from outside the loop. Using 'author_email no comments displayed **/
);
$comments = get_comments($args);
foreach($comments as $comment) :
echo ($comment->comment_content);
endforeach;
?>
【问题讨论】:
标签: wordpress