Changing Most Commented Posts To Most READ Posts (2 posts)

  1. storyofbing
    Posted 3 years ago #

    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) {
      $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 };
      }; ?>


    Thanks in advance!

  2. Jacob Chappell
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.