Wordpress random comment with link to post

Error message

The specified file temporary://filecKdbCP could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

Task to show random comment with link to post. The decision below. First we get all approved comments. If we have comments we get random number among of existing, then we print comment content, and put link to commented post. Thats all, we spent some time to do it and we hope our solution will be useful for you.   

<?php
           $comments = get_comments("post_id=$post_id&status=approve");
        
           if ($comments) {
           $ndx = mt_rand(1,sizeof($comments)) - 1;
           $comment = $comments[$ndx];
           }
      ?>

      <p><?php echo $comment->comment_content; ?></p>
      <a href="<?php  print get_permalink( $comment->comment_post_ID); ?>" >Read more ...</a>
Rating: 
0 out of 10 based on 0 ratings.