Skip to content

Instantly share code, notes, and snippets.

@jonathan-dejong
Created March 2, 2020 08:14
Show Gist options
  • Save jonathan-dejong/08d1957bf75271e7b33d65dbc0c0d854 to your computer and use it in GitHub Desktop.
Save jonathan-dejong/08d1957bf75271e7b33d65dbc0c0d854 to your computer and use it in GitHub Desktop.
Drop cache on ACF options page update
// This is in the context of a namespaced class.
public function acf_save_post( $post_id ) {
// Retrieves all acf option page slugs.
$option_slugs = array_unique(
array_map(
function( $options_page ) {
return $options_page['post_id'];
},
acf_get_option_pages()
)
);
// This is not the post_id you're looking for…
if ( ! in_array( $post_id, $slugs, true ) ) {
return;
}
// Drop it like it's hot!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment