<ol>
<?php
$args= array(
'status' => 'approve',
'type' => 'comment',
'post_status' => 'publish',
);
$comments_query= new WP_Comment_Query;
$comments = $comments_query->query( $args );
$html= '<li><p>%1$s</p><article><h2><a href="%2$s">%3$s</a></h2>Author: <span>%4$s</span>Date: %5$s<div>%6$s</div></article></li>';
if ( $comments ) {
foreach ( $comments as $comment ) {
$id = absint( $comment->comment_post_ID );
$post_data= get_post( $id );
if ( $id !== $copied_id ) {
printf( $html ,
wp_html_excerpt( $comment->comment_content , 60, '...' ),//コメント
esc_url( get_permalink( $id ) ),//投稿URL
wp_html_excerpt( $post_data->post_title , 40, '...' ),//投稿タイトル
get_the_author_meta('nickname', $post_data->post_author ),//投稿者ニックネーム
$post_data->post_date,//投稿日
wp_html_excerpt( $post_data->post_content , 60, '...' )//投稿の概要
);
}
$copied_id= $id;
}
}
?></ol>
カテゴリを指定して表示する場合は、上記の関数内の以下の部分を修正すればよさそうです。
$post_data= get_post( $id );
$category= has_category( 4, $id );//カテゴリ判定
if ( $id !== $copied_id && $category) {