找到了答案。查看wp评论帖子。php有一个名为comment_post_redirect
我用它来检查评论是否被批准,然后在URL中添加一个查询字符串。太简单了。
//A query string needs to be added when redirecting back to the post after a comment is posted and not approved. This ensures the page with the "Your comment is awaiting moderation." message won\'t be cached by the CDN and seen by the rest of the world.
function add_query_string_to_comment_redirect($location, $comment) {
if( !$comment->comment_approved ) {
$location = add_query_arg( array( \'moderated\' => \'\' ), $location);
}
return $location;
}
add_filter(\'comment_post_redirect\', \'add_query_string_to_comment_redirect\', 10, 2);