如何在wordpress中编辑这段代码

How to edit this code in wordpress

我有一个名为 EasyVersion: 1.2 By D5 Creation 的主题。对于评论框部分,我想更改文本,使其显示与 Post 评论不同的内容。我到处找啊找,甚至用所有文件搜索来找代码。

我猜这是代码:

<input id="submit" class="submit" type="submit" value="Post Comment" name="submit">

谁能告诉我如何找到它。它不在 comments.php 或类似的任何地方。

我不太擅长这类事情,所以如果你能清楚地解释我需要做什么那就太棒了。

您的模板很可能呈现默认 <?php comment_form(); ?> 或类似的内容。有几种方法可以解决这个问题。

第一种方法是简单地在进行此调用的模板中找到对 comment_form() 的调用,然后传入如下参数:

<?php comment_form(array('label_submit' => __('Post an awesome Comment'))); ?>

另一种方法 - 请记住,我还没有测试它 - 是通过操作挂钩全局更改默认字段。

functions.php中添加以下内容:

add_filter('comment_form_defaults', 'modify_comment_fields');
function modify_comment_fields($fields){
    $fields['label_submit'] = __('Post an awesome Comment');
    return $fields;
}

这应该会让你走上正确的轨道。

More information on comment_form() here