After couple of nights of searching and trying various approaches, I haven't found any solution.


Cache not clearing after saving manually 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. The changes can be seen when 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. So the values are not fetched from the database, but from cache. 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 is the right way to flush Wordpress's cache?

What have been tried

This is what I have already tried: After update_field() I've run:






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.


Forgot to mention earlier, that no Cache plugins is being used.

  • So where's the cache then? WordPress doesn't cache things between requests AFAIK, unless you set up a cache plugin or an object cache. Are you sure it's not just your browser cache?
    – Rup
    Commented Oct 14, 2021 at 19:58
  • @Rup Wordpress seems to have it's own Object cache. This is something new for me too. More info: developer.wordpress.org/reference/classes/wp_object_cache Commented Oct 14, 2021 at 20:05
  • True but it won't cache across requests unless you add use a plugin to e.g. move the cache into memcached: "By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request."
    – Rup
    Commented Oct 14, 2021 at 20:07
  • Well, if that's the case, then I'm really confused with this issue. I can see in my database, that meta data X has a value A, but frontend displays value B. If this is not caused by cache, then what could it be? Commented Oct 14, 2021 at 20:14
  • 1
    @tiagocalado I doubt it's something to do with variables. Any of used variable doesn't apply both in this tool and on frontend. Ie. tool uses diffrent variables (in different class) than frontend. I have narrowed down the reason of this issue and it's related to Advanced Custom Fields. When I pull the metadata out with get_post_meta(), I get the correct data while ACF get_field() function is showing the wrong data. I have posted this same question to ACF support forum, but I'll leave this question here, if someone with same issue has an answer. Commented Oct 15, 2021 at 10:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.