wordpres 自定义comment样式

http://wange.im/diy-wordpress-comment-style.html

 

复制代码
function mytheme_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>

    <article>
<div class="cell hoverable reply" id="comment-<?php comment_ID(); ?>">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td valign="top" width="48">
<a href="http://forum.tianming.me/index.php/user/info/2" class="profile_link" title="hurner">
<img alt="hurner medium avatar" class="medium_avatar" src="http://forum.tianming.me/uploads/avatar/default.jpg">
</a>
</td>
<td width="10"></td>
<td valign="top" width="auto">
<div class="fr">
<small class="snow">
#3 -
4 天前
<a href="#reply" onclick="replyOne('hurner');"><img align="absmiddle" alt="Reply_button" border="0" id="mention_button" class="clickable mention_button" data-mention="hurner" src="http://forum.tianming.me/static/images/reply_button.png"></a>
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</small>
</div>
<a href="http://forum.tianming.me/index.php/user/info/2" class="dark startbbs profile_link" title="hurner">hurner</a>
<span class="snow">&nbsp;&nbsp; 
<div class="sep5"></div>
<div class="content reply_content"><?php comment_text() ?></div>

</span></td>
</tr>
</tbody></table>
</div>
</article>


<?php
        }
复制代码

如下调用:

复制代码
                <?php
                //Gather comments for a specific page/post 
                $comments = get_comments(array(
                    'post_id' => $post->ID,
                    'status' => 'approve' //Change this to the type of comments to be displayed
                    ));

                //Display the list of comments
                wp_list_comments(array(
                    'per_page' => 10, //Allow comment pagination
                    'reverse_top_level' => false, //Show the latest comments at the top of the list
                    'callback'=> 'mytheme_comment',
                    ), $comments);
                ?>
复制代码

原始的评论输入框,如下comment_reply_link使用:

<div class="commen-form">
    <?php
    $args = array(
        'id_form' => 'commentform',
        );
    comment_form($args);
    ?>
</div>

  

posted @   hurner  Views(411)  Comments(0Edit  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示