在Wordpress中自定义wp_list_comments中的子级注释 [英] Customizing children comments in wp_list_comments in wordpress
本文介绍了在Wordpress中自定义wp_list_comments中的子级注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要的是这样的:单击以查看图片
但是,最后它是这样的:
单击以查看图片
(我不能放图片,所以我放图片网址
But,at last It came up with like this: Click to see the picture (I can't put images, so I put the picture url here!)
这里是代码在我的comment.php中显示注释的地方:
Here Is Code In My comment.php Where Show The Comments:
`<?php wp_list_comments('type=comment&callback=comment_activity_list');?>`
,这是我的function.php中函数 comment_activity_list的代码:
and this is the code of function "comment_activity_list" in my function.php:
<?php if (!function_exists("comment_activity_list")){
function comment_activity_list($comment, $args, $depth){
$GLOBALS['comment'] = $comment;
?>
<ol class="clist">
<li id="discussion-<?php comment_ID() ?>" class="discussion">
<div class="discussion-post clearfix">
<div class="gravatar"><?php echo get_avatar( $comment, 45); ?></div>
<div class="block">
<a class="discussion-username"><?php echo get_comment_author_link() ?></a>
<div class="discussion-text">
<?php comment_text()?>
<?php if ($comment->comment_approved == '0') : ?>
<p><em><?php _e('Your comment is awaiting moderation.'); ?></em></p>
<?php endif; ?>
</div>
<!--.discussion-text-->
<div class="discussion-meta">
<?php delete_comment_link($comment->comment_ID,'class="btn red"')?>- <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> - <?php if(!function_exists('how_long_ago')){comment_date('M d, Y'); } else { echo how_long_ago(get_comment_time('U')); } ?>
</div>
<!--.discussion-meta-->
</div>
<!-- .discussion-post -->
</div>
<!-- .discussion-post -->
</li>
</ol>
<?php
}
}?>
如何自定义儿童注释?任何人都可以帮助我吗?
How can I Customize the children comments ? Any one can hepl me?
提前谢谢!
推荐答案
您可以通过检查以下内容来检查注释是否为儿童
You can check if a comment is a child by checking the following
<?php if( $comment->comment_parent ) : ?>
// This is a CHILD comment
<?php else: ?>
// This is a NORMAL comment
<?php endif; ?>
这篇关于在Wordpress中自定义wp_list_comments中的子级注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文