管理者からコメントに対する返信一覧を表示する
<?php
$html = '<p><span>%1$s</span> <span>%2$s さんへ</span> <br />%3$s</p>';
$args = array( 'status'=> 'approve',
'type' => 'comment',
'user_id'=> '1',//管理者ID
);
$comments_query= new WP_Comment_Query;
$comments = $comments_query->query( $args );
if ( $comments ) {
foreach ( $comments as $comment ) {
if( $comment->comment_parent !== "0" ) {
printf($html,
esc_html( get_comment_date( 'Y m d', $comment->comment_ID ). ' ' . get_comment_date( 'H:i', $comment->comment_ID )),
esc_html( get_comment_author( absint( $comment->comment_parent ) ) ),
get_comment_text( $comment->comment_ID )
);
}
}
} else {
echo 'No comments found.';
}
?>