When I use the following code, everything shows except the reply link! Anybody know what I’ve done wrong? I’d like the link to show up with the word ‘Reply.’
Live example: http://themeforward.com/demo2/?p=1948#commentlist
In my header:
<?php
if ( is_singular() && comments_open() && get_option('thread_comments') )
wp_enqueue_script( 'comment-reply' );
?>
In comments.php:
<?php if($comments) : ?>
<?php foreach($comments as $comment) : ?>
<li id="comment-<?php comment_ID(); ?>">
<?php if ($comment->comment_approved == '0') : ?>
<p>Your comment is awaiting approval</p>
<?php endif; ?>
<?php if(function_exists('get_avatar')) { echo get_avatar($comment, '60'); } ?>
<cite class="fn"><?php comment_author_link(); ?> on <?php comment_date(); ?> at <?php comment_time(); ?></cite>
<?php echo comment_reply_link(array('depth' => $depth, 'max_depth' => $args['max_depth'])); ?>
<?php comment_text(); ?>
</li>
<?php endforeach; ?>
<?php else : ?>
<p>No comments yet</p>
<?php endif; ?>
My suggestion would be twofold:
comment-reply
scriptwp_list_comments()
Enqueueing
comment-reply
I would recommend hooking into
comment_form_before()
:Outputting the comment list
Using
wp_list_comments()
with default output in your code:If you need specific markup for the comment list, you can pass a callback as a parameter to
wp_list_comments()
. But I would strongly recommend making sure everything works with the default output first, and then try to customize.You can use your own custom markup in a callback, but you’ll need to be sure to define the variables you’re using, such as
$depth
and$args
. If you can provide specific markup questions, I can help construct the callback.You’re simply missing the comment reply script. Enqueue it and you’re don.
If you are using
wp_list_comment
with a custom callback, ie:Then make sure that you pass the right depth parameters when calling
comment_reply_link
inside that callback, just like this: