[英]HTML5 Video View count
Need help in counting the video view count.需要帮助计算视频观看次数。 I am using Wordpress.
我正在使用 Wordpress。 Or does anyone know any plugin that will count the video views.
或者有谁知道任何可以计算视频观看次数的插件。 Also this is not embedded video.
这也不是嵌入式视频。 The video location is on my server.
视频位置在我的服务器上。
This code Punt in function.php
这段代码在
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);
}
}
Put count value use code and pass post id
in single page将计数值使用代码并在单个页面中传递
post id
<?php setPostViews(1); ?>
Get Count value use code and pass post id
获取计数值使用代码并传递
post id
<?php getPostViews(1); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.