使用comments\\u数组过滤器,删除不必要的注释。
一些松散的代码让你开始
<?php
add_filter(\'comments_array\',\'display_only_user_comments\')
function display_only_user_comments($comments){
$comemnts=NULL;
/*modify this part to get only user comments*/
if ( $user_ID) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = \'1\' OR ( user_id = %d AND comment_approved = \'0\' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
} else if ( empty($comment_author) ) {
$comments = get_comments( array(\'post_id\' => $post->ID, \'status\' => \'approve\', \'order\' => \'ASC\') );
} else {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = \'1\' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = \'0\' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));
}
return $comments;
}
?>