This may sound like an unusual request but I am try to display comments from several related posts in a single comment template.

For example I have several posts on the same topic (IDs 253, 724, 798) and I want all comments from these posts to appear next in a continuous thread. So if I am viewing post ID 724 I can also see the comments from posts 253 and 798.

Can I pass multiple post IDs to the comments template to achieve this does this require a custom query before or after the comments template to show all the comments in a merged thread?

2 Answers
2

you can get comments from each post by its id with

$comments253 = get_comments('post_id=253');
$comments724 = get_comments('post_id=724');
$comments798 = get_comments('post_id=798');

then merge ( array-merge ) and sort the array by date ( comment->comment_date being the key to the date value) if you want.
then just

 foreach($comments as $comment) :
      echo($comment->comment_author . '<br />' . $comment->comment_content);
 endforeach;

This is all very manual, and you might want to automatize the process, but that’s probably an different matter.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *