WP评论模板更改子评论包装

时间:2018-11-29 19:37:15

标签: php wordpress comments

如何将WP子注释换行从ul class="children"更改为div class="children"
为什么需要?
W3标记验证服务错误-“在此情况下,元素div不允许作为元素ul的子元素。”

我习惯在single.php中输出

<?php comments_template();?>

我来自comments.php的自定义代码

<div class="comment-form-wrap">
<?php
    $fields = array(
      'author' => '<div class="row">
                      <div class="col-md-6">
                        <input placeholder="'.__('Your name', 'moja').'" type="text" id="author" name="author" value="'.esc_attr($commenter['comment_author']).'" maxlength="30" pattern="[A-Za-zА-Яа-я0-9]{3,}" autocomplete="on" tabindex="1" required aria-required="true">
                      </div>',
      'email'  =>   '<div class="col-md-6">
                        <input placeholder="'.__('Your email', 'moja').'" type="email" id="email" name="email" value="'.esc_attr($commenter['comment_author_email']).'" maxlength="30" autocomplete="on" tabindex="2" required aria-required="true">
                      </div>
                  </div>',
      'url' =>  '<input type="url" id="url" name="url" class="site" value="' . esc_attr($commenter['comment_author_url']) . '" placeholder="www.example.com" maxlength="30" tabindex="3" autocomplete="on">'
    );

    $args = array(
      'comment_notes_after'  => '',
      'cancel_reply_before'  => __('Reply comment', 'moja'),
      'cancel_reply_after'   => '',
      'cancel_reply_link'    => __('Cancel reply', 'moja'),
      'title_reply'          => '',
      'comment_field'        => '<div class="row"><div class="col-lg-12">
                                    <textarea placeholder="'.__('Write a comments here', 'moja').'" id="comment" name="comment" cols="45" rows="6" required></textarea>',
      'class_submit'         =>     'btn ripple',
      'submit_button'        =>     '<button type="submit" id="%2$s" class="%3$s">'.__('Reply comment', 'moja').'</button>',
      'submit_field'         =>     '%1$s %2$s
                                 </div></div>',
      'class_form'           => '',
      'comment_notes_before' => '',
      'fields' => apply_filters('comment_form_default_fields', $fields)
    );
    comment_form($args);?>
</div>

<?php $comm_num = get_comments_number(); if ($comm_num > 0) : ?>

<div class="article-comments-list">
    <div itemprop="interactionCount" class="article-comments-count d-flex align-items-center">
        <svg><use xlink:href="#icon-comments"></use></svg>
        <?php printf( _n( '%s comment', '%s comments', $comm_num, 'moja' ), number_format_i18n( $comm_num ) );?>
    </div>
    <div class="comments">
    <?php function article_comment($comment, $args, $depth) {
            $GLOBALS['comment'] = $comment;?>
        <div id="comment-<?php echo $comment->comment_ID;?>" class="comment-wrap" itemprop="comment" itemscope="itemscope" itemtype="http://schema.org/UserComments">
            <?php if( $depth > 1 )
                echo '<svg class="comments-answer-icon"><use xlink:href="#icon-answer"></use></svg>';
            ?>

            <div class="comments-info-wrap d-flex align-items-center">
                <figure><?php
                echo get_avatar( $comment->comment_author_email, 48, null, $comment->comment_author );
              ?></figure>
                <div class="comments-info">
                    <cite itemprop="creator"><?php echo $comment->comment_author;?></cite>
                    <span class="comment-time"><?php comment_date('d/m/Y');?></span>
                    <meta itemprop="commentTime" content="<?php comment_date('Y-m-d');?>">
                </div>
            </div>
            <div class="comment-text" itemprop="commentText">
                <?php comment_text();?>
            </div>
            <div class="comment-respond">
                <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'])));?>
            </div>
        </div>
    <?php }
        $args = array(
            'reply_text'    => '<svg><use xlink:href="#icon-respond"></use></svg>'.__('Reply', 'moja'),
            'callback'      => 'article_comment'
        );
    wp_list_comments($args);?>
    </div>
</div>

<?php endif;?>

*尽管我认为该代码几乎应在每个项目中使用,但我无法完全找到该问题的答案。

0 个答案:

没有答案