marcboivin
Member
Posted 1 year ago #
I'm looking for a way to allow my users to browse my blog by most commented posts. Googling for it led to nothing really.
I'm guessing I would need to hook the redirecting functions, add support for a canonical tag like /by-comment/, but really I don't know where to start from.
Any ideas?
TIA
interested in a plugin at all?
I use:
http://wordpress.org/extend/plugins/most-commented/
but rather than widget I use it in my archive template
which works with this bit of code:
<?php if( function_exists('mdv_most_commented') ) : ?>
<h6><?php _e( 'Most Commented Posts', 'voodoo_lion' ); ?></h6>
<ul>
<?php mdv_most_commented(10); ?>
</ul>
<?php endif; ?>
to show my ten most commented post titles....
You could do this using WP_Query to create a query ordered by comment count.
Example
<?php
$most_comments_posts = new WP_Query;
$most_comments_posts->query( array(
'posts_per_page' => 10,
'orderby' => 'comment_count',
'order' => 'desc'
) );
if( $most_comments_posts->have_posts() ) :
while( $most_comments_posts->have_posts() ) :
?>
<!-- example html area -->
<div class="example">
<?php
// Like a regular loop, you can place the various template tags here: http://codex.wordpress.org/Template_Tags
the_title(); // Example
?>
</div>
<!-- example html area -->
<?php
endwhile; // End loop
endif; // End if loop has posts
?>