所以,我在这里为我的社区网站使用 Boombox 主题,我想显示来自用户的“总帖子阅读/浏览量”,例如,A 用户有 10 个帖子并且每个帖子都有不同的视图,我需要来自所有用户的总视图A的帖子。可以在wordpress平台上做吗?因为我在我的数据库表中找到了,所以我找不到任何我可以“玩”的相关字段。
我尝试修改 update_post_meta 函数,尝试在 function.php 文件中添加另一个条件,但它不起作用。
这是功能:
function boombox_update_post_total_view( $scale, $post_id ) {
if( absint( $scale ) > 0 ) {
$total = intval( boombox_get_post_meta( $post_id, 'total_views' ) );
$total += $scale;
update_post_meta( $post_id, 'total_views', $total);
}
}
add_action( 'boombox/view_total_updated', 'boombox_update_post_total_view', 10, 2 );
这是数据库表结构: 数据库表结构
谢谢你。注意:我什至不确定我是否编辑了正确的文件。