【发布时间】:2018-03-24 11:22:47
【问题描述】:
我有一个按作者列出 cmets 的代码。我在 author.php 中使用它。它完美地列出了 cmets,但如果作者没有 cmets,它会显示其他作者的评论链接。
代码
<?php
$args = array(
'user_id' => get_the_author_meta('ID'),
'number' => 5, // how many comments to retrieve
'status' => 'approve'
);
$comments = get_comments( $args );
if ( $comments )
{
foreach ( $comments as $c )
{
$output.= '<li">';
$output.= '<a href="'.get_comment_link( $c->comment_ID ).'">';
$output.= get_the_title($c->comment_post_ID);
$output.= "</a></li>\n";
}
echo $output;
} else { echo "There is no comment yet.";}
?>
如果作者没有评论,我想在这里查看:else { echo "There is no comment yet.";}
【问题讨论】:
标签: wordpress comments author codex