Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#8204 closed defect (bug) (invalid)

get_comment_reply_link not working in callback

Reported by: jeremyclark13's profile jeremyclark13 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Comments Keywords: callback, comments, get_comment_reply_link
Focuses: Cc:

Description

The get_comment_reply_link function doesn't work when using a callback to customize the output of wp_list_comments This is a sample of the code I'm using.

function custom_comment($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID( ); ?>">
       <div class="avatar_cont"><?php echo get_avatar( get_comment_author_email(), '50' ); ?></div>
Comment by <em><?php comment_author_link() ?></em>:
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />
<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('l, F jS Y') ?> 
at <?php comment_time() ?></a>&nbsp;|&nbsp;<?php edit_comment_link('Edit','',''); ?></small>

	<?php comment_text() ?>

<div class="reply">
<?php echo get_comment_reply_link(); ?>
</div>
<?php
}

Most of this was taken from this example by Ryan here.

Change History (6)

#1 @ryan
16 years ago

I think you have to pass depth for it to do anything. Maybe we should default to always showing the link if no depth is passed.

#2 @jeremyclark13
16 years ago

I should have mentioned that it doesn't work with this code either.
<?php echo comment_reply_link(array('depth' => $depth, 'max_depth' => $args['depth'])) ?>
I think that defaulting to always showing would be a good idea.

#3 @jeremyclark13
16 years ago

Okay I think I figured out the problem. It looks like the $args['depth'] isn't working. If I manually set the max_depth then the link shows up. So if I use code like this then it works.
<?php echo comment_reply_link(array('depth' => $depth, 'max_depth' => 5)); ?>

#4 @ryan
16 years ago

Oh, there was an API change done for #8018.

#5 @jeremyclark13
16 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Changing to this does in fact work.
<?php echo comment_reply_link(array('depth' => $depth, 'max_depth' => $args['max_depth'])); ?>
Thanks Ryan

#6 @thee17
16 years ago

  • Milestone 2.7 deleted
Note: See TracTickets for help on using tickets.