Note that the function wp_list_comments()
doesn’t fetch the comments, only displays them in various ways depending on the input arguments.
You’re actually using the WP_Comment_Query
/get_comments
input arguments into wp_list_comments()
.
You could try this instead:
$postID = 12345; // Adjust this!
$comments = get_comments(
[
'date_query' => [
'after' => '5 minutes ago',
'inclusive' => true,
],
'post_id' => $postID,
'status' => 'approve',
]
);
printf(
'<ol>%s<ol>',
wp_list_comments( $args = [ 'echo' => 0 ], $comments )
);
where you can play with the comment output through the $args
input array.
Check the Codex here.
Note that we can skip the before
attribute when we use after
attribute.