Custom Callback for Comments
-
Hi, I don’t know why but my code isn’t working for a custom callback in the wp_list_comments(), but let me explain; this is the code that works well:
<?php if( ! function_exists( 'better_comments' ) ): function better_comments($comment, $args, $depth) {?> <span> <a href="#"><i class="fa fa-reply"></i> <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></a></span> <?php } endif;So, the comment_reply_link() works… But, when I add some html customization, I got this error: “Notice: Undefined index: max_depth” pointing on the array inside comment_reply_link(). This is the code with html customization:
if (!function_exists('better_comments')): function better_comments($comment, $args, $depth) { ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>"> <div class="row comment clearfix pl-3 pb-2"> <div class="col-auto p-0"> <?php echo get_avatar($comment,$size='40',$default='',$alt='', $args=array('class'=>'comment-thumbnail')); ?> </div> <div class="col"> <div class="bg-dark p-2 comment-radius"> <p class="m-0 px-2"><span class="commentatore"><?php comment_author(); ?> </span><?php echo get_comment_text(); ?></p> </div> <span><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?></span> </div> </div> <?php } endif;Can someone solve this issue? I really don’t know why with some html customization I got that error.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Custom Callback for Comments’ is closed to new replies.