Home › Forums › Front-end Issues › ACF backend cache › Reply To: ACF backend cache
After doing some digging in your ACF code, I may have a more targeted solution from the acf_get_value()
function. This is untested, but assuming this is where the value is cached, it should easily be cleared on post update hook.
public function acf_clear_object_cache( $post_id ) {
if ( empty( $_POST['acf'] ) ) {
return;
}
// clear post related cache
clean_post_cache( $post_id );
// clear ACF cache
if ( is_array( $_POST['acf'] ) ) {
foreach ( $_POST['acf'] as $field_name => $value ) {
$cache_slug = "load_value/post_id={$post_id}/name={$field_name}";
wp_cache_delete( $cache_slug, 'acf' );
}
}
}
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.