I've got to update a bit of sloppy code that shows the 5 most recent comments across the entire blog. The code is using WordPress'
get_comments() method, which doesn't appear to return comment id's, or comment links (direct links to comments within posts via the hash-tag).
How can I collect more information about the particular comments, and make them links to the actual comments within their parent pages?
<h3>Recent Comments</h3> <ul> <?php $comments = get_comments(array('status'=>'approve','number'=>'5')); ?> <?php foreach ($comments as $comment): ?> <?php $post = get_post($comment->comment_post_ID, 'OBJECT'); ?> <li><?php print $comment->comment_author; ?> on <a href="<?php print get_permalink($post->post_ID); ?>"> <?php print $post->post_title; ?> </a> </li> <?php endforeach; ?> </ul>
This is located on the front page of the site, outside of the loop.