Support » Plugins » 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.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Elsnare,
    Did you fin a solution? I am having the same question.
    Thank !

    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 🙂

    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.