<?php
if(is_singular('post')){
$count = get_field('views');
$count++;
update_field('views', number_format($count,0,",","."));
}
?>
Through the above code, the post views can be realized, and the refresh will increase by 1. Now I want to count the views of all post on the whole site. How should I count them?
The only way to do this without querying the DB directly would be to do a query to get all posts, loop over all the posts, get the count field and add them up.