我正在为自己构建一个Wordpress主题,而且我的评论表单存在问题。我想更改回复“按钮”的文本(实际上它不是一个按钮,它是一个带有onclick功能的a-class)。现在默认为“回复”,但我想将其更改为其他内容。怎么办?
我的php文件如下所示:
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains comments and the comment form.
*
*/
/*
* If the current post is protected by a password and the visitor has not yet
* entered the password we will return early without loading the comments.
*/
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die('Please do not load this page directly. Thanks!');
if (post_password_required()) {
?>
<p class="nocomments">Det här inlägget är lösenordsskyddat. Knappa in lösenordet för att se inlägget.</p>
<?php
return;
}
?>
<div id="commentsbox" class="post">
<?php if (have_comments()) : ?>
<h3 id="comments">
<?php comments_number('Inga kommentarer',
'En kommentar',
'% kommentarer'); ?>
än så länge.</h3>
<ol class="commentlist">
<?php wp_list_comments(array(
'avatar_size' => 70)); ?>
</ol>
<div class="comment-nav">
<div class="alignleft">
<?php previous_comments_link() ?>
</div>
<div class="alignright">
<?php next_comments_link() ?>
</div>
</div>
<?php else : ?>
<?php if (comments_open()) : ?>
<?php else : ?>
<p class="nocomments">Kommentarer är avstängda</p>
<?php endif; ?>
<?php endif; ?>
<?php if (comments_open()) : ?>
<div class="commentform_wrapper">
<div class="post-info">
</div>
<div id="comment-form">
<?php $comment_args = array( 'title_reply'=>'Vänligen lämna dina synpunkter och kommentarer:',
'title_reply_to' => __( 'Svara %s' ),
'cancel_reply_link' => __( 'Stäng svar' ),
'label_submit'=>'Skicka',
'reply_text' => 'Svara',
'fields' => apply_filters( 'comment_form_default_fields', array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Namn' ) . '</label> ' . ( $req ? '<span>*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email">' .
'<label for="email">' . __( 'Mejl' ) . '</label> ' .
( $req ? '<span>*</span>' : '' ) .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' />'.'</p>',
'url' => '' ) ),
'comment_field' => '<p>' .
'<label for="comment">' . __( 'Kommentarer' ) . '</label>' .
'<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' .
'</p>',
'comment_notes_after' => '',
);
comment_form($comment_args); ?>
</div>
</div>
<?php endif; ?>
</div>
使用firebug进行检查时,我想要访问的代码如下所示:
<a class="comment-reply-link" onclick="return addComment.moveForm("div-comment-3", "3", "respond", "40")" href="/?p=40&replytocom=3#respond">Reply</a>
答案 0 :(得分:3)
添加到functions.php:
function custom_comment_reply($content) {
$content = str_replace('Reply', 'Reply to this comment', $content);
return $content;
}
add_filter('comment_reply_link', 'custom_comment_reply');
更改“回复” - “回复此评论”。