Find the comment’s post title

I am trying to create a plugin what will be a sime kind of a comments archive.
I have looked at get_comment().

I am looking to show where the comment came from, specifically the title of the post where the comment is attached. This is part of my code:

Read More
if ( $comments ) {
  foreach ( $comments as $comment ) {
    // here you can display the comment in the way you want

    echo 'from: ' . $comment->i want comment post title here . '<br/>';
    echo '<p>' . $comment->comment_content . '</p>';
  }
}

How to do this?

Related posts

Leave a Reply

1 comment

  1. Here is how you do it:

    <?php
        if ( $comments )
            foreach($comments as $comment){
                // here you can display the comment in the way you want
    
                echo 'from: ' . get_the_title($comment->comment_post_ID) . '<br/>';
                echo '<p>' . $comment->comment_content . '</p>;
            }
    ?>