Support » Fixing WordPress » Changing Most Commented Posts To Most READ Posts

  • I use a tabbed widget that shows Recent, Popular and Random Posts.

    The tab for Popular Posts current shows posts with highest number of comments.

    I would like to change that to posts with highest number of VIEWS.

    Is that possible? The current php script is like this –

    <div id=”popular-tabbed” class=”tab”>

      <?php global $wpdb;
      $result = $wpdb->get_results(“SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $popularPostsNumber”);
      foreach ($result as $post) {
      #setup_postdata($post);
      $postid = $post->ID;
      $title = $post->post_title;
      $commentcount = $post->comment_count;
      if ($commentcount != 0) { ?>
      <?php query_posts(“p=$postid”); ?>
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <?php include(TEMPLATEPATH . ‘/includes/fromblog_post.php’); ?>
      <?php endwhile; endif; wp_reset_query(); ?>
      <?php };
      }; ?>

    </div>

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • I don’t believe WordPress stores post views by default. I could be wrong but I’ve never seen anything that suggests it would.

    You could implement this functionality yourself via a plugin though.

Viewing 1 replies (of 1 total)
  • The topic ‘Changing Most Commented Posts To Most READ Posts’ is closed to new replies.