繁体   English   中英

HTML5 视频观看次数

[英]HTML5 Video View count

需要帮助计算视频观看次数。 我正在使用 Wordpress。 或者有谁知道任何可以计算视频观看次数的插件。 这也不是嵌入式视频。 视频位置在我的服务器上。

这段代码在function.php

function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count;
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}

将计数值使用代码并在单个页面中传递post id

<?php setPostViews(1); ?>

获取计数值使用代码并传递post id

<?php getPostViews(1); ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM