Customizing children comments in wp_list_comments

2019-07-29 03:07发布

问题:

What I want is like this: Click to see the picture

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!)

Here Is Code In My comment.php Where Show The Comments:

`<?php wp_list_comments('type=comment&callback=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?

Thx In Advance!

回答1:

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; ?>