如何更改#回复标题的I18N/L10N?(旧标题:评论回复链接不起作用)

时间:2015-06-03 作者:joschi81

I\'m developing a new theme and plugins for it. Unfortunately, the comment reply link is broken. Instead of moving the comment reply textarea, the page is reloaded by adding e.g. ?replytocom=2#respond to the URL (corresponding to the value of the href attribute).

Here\'s a link to see what I mean:... (No longer necessary to view link)

Thanks in advance for your help!

Bestjoschi81

EDIT: I found out that it\'s caused by my "dirty" hack to modify the #reply-title. Which I do like this: functions.php.

// add variable to change comment form title
function add_comment_title_variable($content) {
    $output = $content;
    if(is_single() && comments_open()) $output .=\'<script type="text/javascript"> var commentFormTitle = "\'.__(\'Leave a comment\',\'theme-text-domain\').\'"; </script>\';
    return $output;
}
add_filter(\'the_content\',\'add_comment_title_variable\');

Main JS file of my theme:

$(document).ready(function(){
    // [...]
    if(typeof(commentFormTitle) != \'undefined\') $(\'#reply-title\').html(commentFormTitle);
});

So, any hints how I can "individualize" the translation/textoutput of the comment form title without such dirty hack?

I kept it within the same question as other people who have the same problem with the comment reply link might be causing it the same way.

Thanksjoschi81

2 个回复
SO网友:Christine Cooper

因为你需要排队comment-reply.js 这是jQuery效果所必需的。

将以下内容放入header.php 在您的head 标签:

if ( is_singular() && get_option( \'thread_comments\' ) )
    wp_enqueue_script( \'comment-reply\' );

SO网友:joschi81

已解决!我在这里找到了最佳解决方案:https://wordpress.org/support/topic/how-to-change-wording-of-leave-a-reply#post-1881213我添加了主题的textdomain,如下所示:

// individual comment form title
function comment_reform ($arg) {
    $arg[\'title_reply\'] = __(\'Leave a comment\',\'theme-textdomain\');
    return $arg;
}
add_filter(\'comment_form_defaults\',\'comment_reform\');
很抱歉,comment\\u form()函数对我来说仍然有点不清楚,尤其是在筛选默认参数时。

结束

相关推荐

How do comments work?

我在我的管理仪表板中单击“注释”按钮,只看到1条注释。我禁用了我网站上的评论,它甚至不是来自我的网站,而是来自另一个网站,看起来它们链接到了我的帖子。我不明白为什么我在评论部分看到。。。但后来我添加了facebook评论插件(https://wordpress.org/plugins/facebook-comments-plugin/) 我有人在评论。。。但我在我的管理仪表板的评论部分没有看到它们。有人能把这个弄清楚吗?我希望来自facebook的评论能出现在我的评论栏中。就目前而言,我不知道什么时候有人