wordpress 的评论回复表单跟随功能是通过 comment-reply.js 这个 js 实现的。不引入该 js,回复评论时会刷新界面。如何引入该 js,我们可以使用 wp_enqueue_script()这个内置方法。
方式一:在 header.php 中引入
< ?php if ( is_singular() && comments_open() &&(get_option('thread_comments') == 1)){ wp_enqueue_script( 'comment-reply' ); }?>
方式二:在 function.php 使用动作钩子方法实现
//回复评论框跟随
function theme_queue_js(){
if (!is_admin()){
if ( is_singular() && comments_open() && (get_option('thread_comments') == 1)){
wp_enqueue_script( 'comment-reply' );
}
}
}
add_action('get_header', 'theme_queue_js');











