Created
October 1, 2023 17:51
-
-
Save thegulshankumar/741653d61880293071850af39cc71fe3 to your computer and use it in GitHub Desktop.
Bypass Cache on Comment Post
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 | |
/** | |
* Special condition: If your WordPress has a settings to automatically approve all comments without a manual approval | |
* In this case, Cloudflare plugin may not purge the cache. | |
* This is a quick-workaround. After adding this snippet, | |
* you need to create a rule to bypass the Cache for comment-posted=true query string | |
*/ | |
add_filter( 'comment_post_redirect', 'redirect_after_comment' ); | |
function redirect_after_comment( $location ) { | |
$location = add_query_arg( array( 'comment_posted' => 'true' ), $location ); | |
return $location; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment