我创建了一个自定义comments\\u list()函数,它工作得很好,唯一的问题是在父div中显示子注释。它适用于第一和第二深度级别,但不适用于其他深度级别。
这是我的代码:
/* -----------------------------------------------------------------------------
* Comments custom functions
* -------------------------------------------------------------------------- */
//Custom comments lst
function t_one_comments_list( $comment, $args, $depth ) {
$GLOBALS[\'comment\'] = $comment;
switch( $comment->comment_type ) :
case \'pingback\' :
case \'trackback\' : ?>
<li <?php comment_class(); ?> id="comment<?php comment_ID(); ?>">
<div class="back-link"><?php comment_author_link(); ?></div>
<?php
break;
default :
?>
</li>
<?php if ($depth == 1) {?>
<div <?php comment_class(\'media\'); ?> id="comment-<?php comment_ID(); ?>">
<?php if ($comment->comment_approved == \'0\') : ?>
<p><?php _e(\'Your comment is awaiting moderation.\', \'t_one\') ?></p>
<?php endif; ?>
<div class="pull-left">
<?php echo get_avatar( $comment, 100 ); ?>
</div>
<div class="media-body">
<div class="well">
<div class="media-heading">
<strong><?php comment_author(); ?></strong> <small><?php printf( __(\'%1$s\', \'t_one\'), get_comment_date()) ?></small>
<?php edit_comment_link(__(\' Edit\', \'t_one\'), \' \', \'\' ); ?>
<?php comment_reply_link( array_merge( $args, array(
\'reply_text\' => __( \'<i class="fa fa-repeat"></i>Reply\', \'t_one\' ),
\'depth\' => $depth,
\'max_depth\' => $args[\'max_depth\']
) ) ); ?>
</div>
<p><?php comment_text() ?></p>
</div>
<?php if ( $depth + 1) { ?>
<div <?php comment_class(\'media\'); ?> id="comment-<?php comment_ID(); ?>">
<?php if ($comment->comment_approved == \'0\') : ?>
<p><?php _e(\'Your comment is awaiting moderation.\', \'t_one\') ?></p>
<?php endif; ?>
<div class="pull-left">
<?php echo get_avatar( $comment, 100 ); ?>
</div>
<div class="media-body">
<div class="well">
<div class="media-heading">
<strong><?php comment_author(); ?></strong> <small><?php printf( __(\'%1$s\', \'t_one\'), get_comment_date()) ?></small>
<?php edit_comment_link(__(\' Edit\', \'t_one\'), \' \', \'\' ); ?>
<?php comment_reply_link( array_merge( $args, array(
\'reply_text\' => __( \'<i class="fa fa-repeat"></i>Reply\', \'t_one\' ),
\'depth\' => $depth,
\'max_depth\' => $args[\'max_depth\']
) ) ); ?>
</div>
<p><?php comment_text() ?></p>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
<?php // End the default styling of comment
break;
endswitch;
}
使用$depth的正确方法是什么?
提前感谢!