Title: [Plugin: WP Most Popular] View Count
Last modified: August 20, 2016

---

# [Plugin: WP Most Popular] View Count

 *  [rewberl](https://wordpress.org/support/users/rewberl/)
 * (@rewberl)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-view-count/)
 * The best ‘popular post’ plugin I’ve found. If you could, I would appreciate the
   option to display the post count next to the post titles in the widget (perhaps
   in parentheses?). Thank you!
 * [http://wordpress.org/extend/plugins/wp-most-popular/](http://wordpress.org/extend/plugins/wp-most-popular/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [thatwastaxing](https://wordpress.org/support/users/thatwastaxing/)
 * (@thatwastaxing)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-view-count/#post-2565322)
 * +1 (unless it’s resource intensive)
 *  Plugin Author [MattGeri](https://wordpress.org/support/users/mattgeri/)
 * (@mattgeri)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-view-count/#post-2565342)
 * Hi there!
 * Thanks for the feedback.
 * I will definitely add this to the feature list for an upcoming release.
 * Matt
 *  [0x539](https://wordpress.org/support/users/0x539-1/)
 * (@0x539-1)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-view-count/#post-2565346)
 * 6 Months ago, probably not needed anymore but here goes anyway:
 *     ```
       function get_post_views($postID, $period = 'all_time'){
           global $wpdb;
   
           $sql = "
               SELECT
                   *
               FROM
                   {$wpdb->prefix}most_popular mp
               WHERE
                   post_id = {$postID}
           ";
   
           $result = $wpdb->get_row($sql, 'ARRAY_A');
   
           if (is_array($result))
           {
               switch ($period)
               {
                   case 'all_time':
                       return $result['all_time_stats'];
                       break;
                   case '1_day':
                       return $result['1_day_stats'];
                       break;
                   case '7_day':
                       return $result['7_day_stats'];
                       break;
                   case '30_day':
                       return $result['30_day_stats'];
                       break;
                   default:
                       return $result['all_time_stats'];
                       break;
               }
           }
           else {
               return 0;
           }
       }
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: WP Most Popular] View Count’ is closed to new replies.

 * ![](https://ps.w.org/wp-most-popular/assets/icon.svg?rev=1861383)
 * [WP Most Popular](https://wordpress.org/plugins/wp-most-popular/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-most-popular/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-most-popular/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-most-popular/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-most-popular/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-most-popular/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [0x539](https://wordpress.org/support/users/0x539-1/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-most-popular-view-count/#post-2565346)
 * Status: not resolved