您可以尝试使用comment_form_defaults
过滤器:
/**
* Modify the "must_log_in" string of the comment form.
*
* @see http://wordpress.stackexchange.com/a/170492/26350
*/
add_filter( \'comment_form_defaults\', function( $fields ) {
$fields[\'must_log_in\'] = sprintf(
__( \'<p class="must-log-in">
You must <a href="%s">Register</a> or
<a href="%s">Login</a> to post a comment.</p>\'
),
wp_registration_url(),
wp_login_url( apply_filters( \'the_permalink\', get_permalink() ) )
);
return $fields;
});
我们使用
wp_registration_url()
和
wp_login_url()
核心功能。
附言:这个info 在comment_form_defaults
法典中似乎缺少筛选器