Found it.
// TopCommentedPosts widget
class topCommented_Widget extends WP_Widget
{
function topCommented_Widget()
{
parent::WP_Widget(false, $name = __('Top Commented Posts', 'fazio'));
}
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract( $args );
// Extract config vars
$title = apply_filters('widget_title', $instance['title']);
$quantity_to_show = $instance['quantity_to_show'];
if(!is_numeric($quantity_to_show) OR $quantity_to_show == '0')
{
$quantity_to_show = 5;
}
// Make the widget
echo $before_widget;
echo $before_title;
if($title) {
echo $title;
} else {
_e('Top Commented Posts', 'fazio');
}
echo $after_title;
$top = new WP_Query();
$top->query('showposts=' . $quantity_to_show . '&orderby=comment_count');
if($top->have_posts())
{
?>
<ul>
<?php
while ($top->have_posts())
{
$top->the_post();
?>
<li>
<a href="<?php the_permalink();?>"><?php the_title(); ?></a> (<?php echo get_comments_number(); ?>)
</li>
<?php
}
}
?>
</ul>
<?php
echo $after_widget;
}
The “quantity to show” is the number of posts. So if quantity = 5 then it will show the top 5 posts, if quantity = 10 then it shows the top 10 most commented posts.
I don’t know where the actual comment number value is…anyone?