Hi @protoo,
Thank you for contacting us, Please use the below-shared code to achieve what you are looking for.
global $wpdb, $mycred_log_table;
$total_views = $wpdb->get_var( "SELECT COUNT(*) FROM where ref = 'view_content' && ref_id = YOUR_POST_ID {$mycred_log_table}" );
Thread Starter
protoo
(@protoo)
I put the code in single.php but it doesn’t show the view count.
Does the “Viewing content” for post authors work by ip?
Like, does it count each view on a post with each ip address to prevent spam view?
Hi @protoo,
Please use the below-shared code.
global $wpdb, $mycred_log_table;
$total_views = $wpdb->get_var( "SELECT COUNT(*) FROM {$mycred_log_table} where ref = 'view_content' AND ref_id = YOUR_POST_ID" );
replace YOUR_POST_ID with your post id.