My theme is set up to show popular posts on the homepage. I just discovered that it is based on comments count, rather than views. I'd like to change it. The code used in the theme functions php is:
# Displays a list of popular posts
function fs_popular_posts($num, $pre='<li>', $suf='</li>', $excerpt=true) {
global $wpdb, $post;
$querystr = "SELECT $wpdb->posts.post_title, $wpdb->posts.comment_count, $wpdb->posts.ID, $wpdb->posts.post_excerpt FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ORDER BY $wpdb->posts.comment_count DESC LIMIT $num";
$myposts = $wpdb->get_results($querystr, OBJECT);
foreach($myposts as $post) {
echo $pre;
?>
<?php if (fs_settings('popular_thumb')=='enabled') : ?>
<?php fs_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?>
<?php endif; ?>
<a href="<?php echo get_permalink($post->ID); ?>"><?php the_title(); ?></a>
<p><?php echo fs_clean($post->post_excerpt, 140); ?>...</p>
<?php
echo $suf;
}
}
It seems to me all I have to do is change this line: "ORDER BY $wpdb->posts.comment_count DESC LIMIT $num"" but I"m not a programmer.
Can someone tell me what to do to make my popular posts display based on how many views it got rather than # of comments? Thanks so much!!