Title: Exclude comments from loop
Last modified: August 20, 2016

---

# Exclude comments from loop

 *  [elsnare](https://wordpress.org/support/users/elsnare/)
 * (@elsnare)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/exclude-comments-from-loop/)
 * I’m using a comment rating (karma) plugin to display “top rated comments” list
   above the standard comment loop.
 * In comments.php
 *     ```
       <?php global $wp_query;
       	 $comment_arr = $wp_query->comments; usort($comment_arr, 'comment_comparator');
        wp_list_comments('callback=aaa&page=%orderby=comment_karma', $comment_arr); ?>
       ```
   
 * In functions.php
 *     ```
       function comment_comparator($a, $b)
       	{
       	$compared = 0;
       	if($a->comment_karma != $b->comment_karma)
       	{
       		$compared = $a->comment_karma < $b->comment_karma ? 1:-1;
       	}
       	return $compared;
       	}
       	if($a->comment_karma == 0)
       	{
       	$compared = $compared2;
       	}
       ```
   
 * Basically the code checks for rating and sorts comments according to the value,
   the problem is it returns the full list of comments (only sorted via rating),
   where I would like it only to return comments with > 1 rating.
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [delmet](https://wordpress.org/support/users/delmet/)
 * (@delmet)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/exclude-comments-from-loop/#post-3544381)
 * Hi Elsnare,
    Did you fin a solution? I am having the same question. Thank !
 *  Thread Starter [elsnare](https://wordpress.org/support/users/elsnare/)
 * (@elsnare)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/exclude-comments-from-loop/#post-3544382)
 * Unfort. I was not able to solve it the “clean” way.
 * What I ended up doing is putting a display:none; style on the comments from the
   top rated loop to hide them completely on the site. Then using the Karma Comments
   settings I put a display:block!important; style on the high rated comments (so
   the display:none; was overwritten).
 * It works, but like I said it is not a clean way to do this. The “non-rated” comments
   are hidden, then replaced with rated once (in my case) 5+ more of them are rated
   by the users.
 * Still would like to find a better solution 🙂
 *  [delmet](https://wordpress.org/support/users/delmet/)
 * (@delmet)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/exclude-comments-from-loop/#post-3544383)
 * Many thanks! I’ll keep you posted if I find an alternate solution.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude comments from loop’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)

 * 3 replies
 * 2 participants
 * Last reply from: [delmet](https://wordpress.org/support/users/delmet/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/exclude-comments-from-loop/#post-3544383)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
