Skip to content

Instantly share code, notes, and snippets.

@ridinghoodmedia
Forked from jchristopher/functions.php
Last active April 21, 2016 15:03
Show Gist options
  • Save ridinghoodmedia/4bc0b5925feb98d0902604c977b3933f to your computer and use it in GitHub Desktop.
Save ridinghoodmedia/4bc0b5925feb98d0902604c977b3933f to your computer and use it in GitHub Desktop.
<?php
function my_acf_save_post_searchwp( $post_id ) {
// re-index the post
SWP()->purge_post( absint( $post_id ) );
SWP()->trigger_index();
// For some reason the above doesn't work unless there is some sort of output below it??
// The js can be any arbitrary even an alert, which causes an error with acf's redirect function
// but still updates the searchwp index
// Without the code below, the post is purged - i.e. the old meta is not found, but the new meta
// can't be found either
?>
<script>
if (document.referrer != "") {
location.href = document.referrer;
}
</script>
<?php
}
add_action( 'acf/save_post', 'my_acf_save_post_searchwp', 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment