Can not edit comment form

时间:2017-12-26 作者:Nick W

我正在尝试将作者、电子邮件字段添加到评论表单中,但评论表单没有更改。它总是显示一个默认模板,其中只有注释字段和提交按钮。

这可能是缓存问题,还是正在从其他目录读取注释表单模板?

我在页面模板中使用以下代码:

$comments_args = array(
  \'label_submit\' => __(\'コメント送信\'),
  \'title_reply\' => __(\'コメント登録\'),
  \'fields\' => apply_filters(\'comment_form_default_fields\', array(
    \'author\' =>
    \'<p class="comment-form-author">\'.
    \'<input id="author" class="blog-form-input" placeholder="Your Name* " name="author" type="text" value="\'.esc_attr($commenter[\'comment_author\']).
    \'" size="30"\'.$aria_req.
    \' /></p>\',
    \'email\' =>
    \'<p class="comment-form-email">\'.
    \'<input id="email" class="blog-form-input" placeholder="Your Email Address* " name="email" type="text" value="\'.esc_attr($commenter[\'comment_author_email\']).
    \'" size="30"\'.$aria_req.
    \' /></p>\',
  )),
  \'comment_notes_after\' => \'\',
  \'comment_field\' => \'<p class="comment-form-comment"><label for="comment">\'._x(\'Comment\', \'noun\').
  \'</label><br /><textarea id="comment" name="comment" aria-required="true" cols="75"></textarea></p>\',
);
comment_form($comments_args);

1 个回复
SO网友:Jignesh Patel

您可以将此代码放入当前的主题函数中。php文件More Info

<?php

    add_action( \'comment_form_logged_in_after\', \'additional_fields\' );
    add_action( \'comment_form_after_fields\', \'additional_fields\' );
    
    function additional_fields () {
      echo \'<p class="comment-form-title">\'.
      \'<label for="title">\' . __( \'Comment Title\' ) . \'</label>\'.
      \'<input id="title" name="title" type="text" size="30"  tabindex="5" /></p>\';
    }
?>
编辑:

$comments_args = array(
       \'comment_notes_after\' => \'<p><label for="comment">\' . _x( \'NEW\', \'noun\' ) .
    \'</label><input id="new" name="new" aria-required="true">\' .
    \'</input></p>\',
    );

    comment_form($comments_args);

Check more Argument list

enter image description here

结束

相关推荐