donglvchu9143 2017-02-24 08:59
浏览 100
已采纳

自定义html Wordpress评论与头像和回复

I am developing a theme and has no idea how wordpress handles the comment outputs.

I havewp_list_comments in my comments.php, but I'm not sure how to customize the output to get the desired output like this :

enter image description here

this my html code :

  <div class="row">
    <div class="col-sm-2 text-center">
      <img src="https://freeiconshop.com/wp-content/uploads/edd/person-flat.png" class="img-circle" height="65" width="65" alt="Avatar">
    </div>
    <div class="col-sm-10">
      <h4>John Row <small>Sep 25, 2015, 8:25 PM</small></h4>
      <p>I am so happy for you man! Finally. I am looking forward to read about your trendy life. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      <br>
      <p><span class="badge">1</span> Comment:</p><br>
      <div class="row">
        <div class="col-sm-2 text-center">
          <img src="http://www.noviasalcedo.es/wp-content/uploads/2016/05/person-girl-flat.png" class="img-circle" height="65" width="65" alt="Avatar">
        </div>
        <dsiv class="col-xs-10">
          <h4>Nested Bro <small>Sep 25, 2015, 8:28 PM</small></h4>
          <p>Me too! WOW!</p>
          <br>
        </div>
      </div>
    </div>

Any suggestions on how to customize the output rendered by wp_list_comments ?

#update

comments.php:

<div id="comments" class="comments-area">

    <?php if ( have_comments() ) : ?>
        <h2 class="comments-title">
            <?php
                $comments_number = get_comments_number();

                    printf(
                        /* translators: 1: number of comments, 2: post title */
                        _nx(
                            '<p><span class="badge">%1$s</span> Comments:</p><br>',
                            '<p><span class="badge">%1$s</span> Comments:</p><br>',
                            $comments_number,
                            'comments title'
                        ),
                        number_format_i18n( $comments_number )
                    );
            ?>
        </h2>




<ol class="commentlist">
    <?php wp_list_comments('type=comment&callback=mytheme_comment');
   ?>
</ol><!-- .commentlist -->


    <?php endif; // Check for have_comments(). ?>



    <?php
        comment_form( array(
            'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
            'title_reply_after'  => '</h2>',
        ) );
    ?>

</div><!-- .comments-area -->
  • 写回答

2条回答 默认 最新

  • doucigua0449 2017-02-24 09:05
    关注

    You can override the template using the wp_list_comments function.

    Refer to this link.

    You can put that code inside of a function and call that from the wp_list_comments as a callback. All the info on how to do that is in that link.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端