Answer the question
In order to leave comments, you need to log in
How can I collapse all replies to a comment?
The comment thread is rendered like this
<?php
wp_list_comments( array(
'callback' => 'kurs_comment',
'end-callback' => 'kurs_end_comment'
) );
?>
function kurs_comment( $comment, $args, $depth ){
?><div <?php comment_class() ?> id="comment-<?php comment_ID() ?>">
<div class="comment___item">
<div class="comment__author">
<?php echo get_avatar( $comment, 60, '', '', array( 'class' => 'comment___photo' ) ) ?>
<span class="comment__name cormorant"><?php comment_author() ?></span>
</div>
<div class="comment__content">
<span class="comment__date"><?php comment_date( 'j F Y в H:i' ) ?> <?php edit_comment_link( 'Изменить', '<div class="edit__comment">(', ')</div>'); ?></span>
<div class="comment__text"><?php comment_text() ?></div>
<?php comment_reply_link(); ?>
</div>
</div>
<?php // без закрывающего </li> (!)
}
function kurs_end_comment( $comment, $args, $depth ){
echo '</div>';
}
comment_reply_link(); <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
Answer the question
In order to leave comments, you need to log in
Suddenly someone has to.
/*сворачиваем комменты*/
$(".children").after("<a href='#' class='collapce_comment'>Развернуть</a>");
$('.collapce_comment').click(function(){
$(this).closest('.comment').find('.children').slideToggle(300, function(){
if ($(this).is(':hidden')) {
$(this).parent().find('.collapce_comment').html('Развернуть');
} else {
$(this).parent().find('.collapce_comment').html('Свернуть');
}
});
return false;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question