在评论表单中添加以下代码,以在输入框中显示必需内容:
add_filter( 'comment_form_defaults', 'custom_comment_form' );
function custom_comment_form( $args ) {
$args['comment_notes_before'] =
'' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '
';
return $args;
}
此代码将显示一个消息,指示哪些字段是必需的,而不是将用户重定向到wp-comments-post.php。您可以根据您的需要编辑消息的文本。