WordPress.org

Support

Support » Plugins and Hacks » [Plugin: WP Most Popular] View Count

[Plugin: WP Most Popular] View Count

Viewing 3 replies - 1 through 3 (of 3 total)
  • +1 (unless it’s resource intensive)

    Plugin Author MattGeri

    @mattgeri

    Hi there!

    Thanks for the feedback.

    I will definitely add this to the feature list for an upcoming release.

    Matt

    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.