After couple of nights of searching and trying various approaches, I haven’t found any solution.
Issue
I suspect that ACF’s cache is not clearing after saving programmatically post meta.
I’m creating a tool for admins, which will update custom post type’s meta data (ACF-fields) with command update_field()
Changes are being saved to the database and changes can be seen when editing the post. And actually the new values can be seen anywhere in backend.
On the frontend new saved meta data can’t be seen, but there’s old values that doesn’t exist in the database anymore. In other words: on frontend meta data is showing value A, and in database is stored value B.
So the values are not fetched from the database, but from cache, I think. If I update the post in the edit post view, then the new values will show on frontend. But instructing users to go editing post and save it after using this mentioned tool, is not good practice.
So what am I not noticing?
What have been tried
This is what I have already tried: After update_field()
I’ve run:
wp_cache_delete()
clean_post_cache()
update_post_caches()
wp_cache_flush()
$wpdb->flush()
These functions didn’t empty the cache. Am I perhaps using them wrong?
I’m doing the developing in Local by Flywheel, which is using Nginx. I suspected about Nginx and switched to Apache, but that didn’t help. So Nginx isn’t causing the issue. And now as I’m developing the site, there is no cache plugins being used.