This is just a weird problem.
A couple of bits of information here…I’ve been doing some digging.
I installed WP DEBUG and I am only seeing in the Queries tab the value being updated once. I know that it is running twice though. I think the UPDATE sql statement in the logs only once.
Our site does use AJAX, but it is not firing on page load and that is literally all I am doing is just loading the page. When I refresh, I can see the number go up by 2. Like I explained before, if i open up my database and query the post i am on, if i keep refreshing on that query, I will see it update the number twice.
I have read some blogs that are saying that single.php can fire twice before of revisions or something so i added this to functions file.
I also tried moving my function from the functions file to the single.php template. The number still updated twice.
I even tried converting the function into a shortcode and then instead of calling the function directly, I did a do_shortcode in single.php, but it incremented the number twice.
I’ve done site wide searches to see if the function is called anywhere else and it is now only in this one template. The function returns the counter to the page and it only outputs once, but that UPDATE statement seems to fire twice.
I’ll keep playing around with it.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!