I’m using get_comments to show lastest comments i.e.:
<?php
global $comments, $comment;
$comments = get_comments( array( 'number' => '5', 'status' => 'approve', 'post_status' => 'publish' ) );
foreach ( (array) $comments as $comment) {
echo '<li>'.$comment->comment_author.' said '.$comment->comment_content .'</li>'
}
;?>
Is there some way to override admin comments?! I know this tip using SQL but maybe Im’missing something in this function?
Thanks for help.
Updated code
Place this code wherever template file such sidebar.php
, footer.php
and will list latest comments (displaying Admin comments tough).
Yay! We got filters!
Wrapping the result of the
$wpdb
comments query right into a filter callback (and a plugin) is the nice way of handling comments.This one should work (not tested).
Totally untested, but you should be able to use the pre_get_comments filter:
Usage –
Functions.php –
– Tested on wordpress 3.4.1 with TwentyTen theme.