WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. storyofbing
    Member
    Posted 2 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) {
      #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!

  2. Jacob Chappell
    Member
    Posted 2 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

Tags

No tags yet.