トピック投稿者
ksuk
(@ksuk)
WP Ajaxify Comments
https://ja.wordpress.org/plugins/wp-ajaxify-comments/
こちらでいけました!ありがとうございます!
子テーマのfunctions.phpなどで対応する方法を知っている方がいましたら、合わせてお聞きしたいなと考えています。
簡易的な例ですが・・・
functions.php
function my_enqueue_validation_script() {
if ( ! is_single() ) {
return;
}
$script = <<<SCRIPT
(function ($) {
$(function () {
$('form#commentform').submit(function() {
var comment = $(this).find('#comment');
$(this).find('p.error-text').remove();
if ($.trim(comment.val()) == '') {
comment.parent().append('<p class="error-text">このフィールドは必須です。</p>');
return false;
}
return true;
} );
});
}(jQuery));
SCRIPT;
wp_add_inline_script( 'jquery-core', $script );
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_validation_script' );