-
-
Save ridinghoodmedia/4bc0b5925feb98d0902604c977b3933f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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