In functions.php I enqueue comment-reply and also define a callback function for use with wp_list_comments():

function theme_queue_js(){
    if ( 
              ! is_admin() 
           && is_singular() 
           && comments_open() 
           && get_option('thread_comments') 
    )
        wp_enqueue_script( 'comment-reply' );
}
add_action('wp_print_scripts', 'theme_queue_js');


function simple_comment_format($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment; ?>
    <?php if ( $comment->comment_approved == '1'): ?>
    <li <?php comment_class(); ?>>
        <article>
            <time><?php comment_date(); ?></time>
            <h4><?php comment_author(); ?></h4>
            <?php comment_text(); ?>
            <?php comment_reply_link(); ?>
        </article>
    <?php endif;
}

And in comments.php I’ve kept things pretty minimal:

<section id="comment-form">
  <?php comment_form() ?>
</section>

<?php if ( have_comments() ): ?>
    <section class="commentlist">
        <h2>Comments!</h2>
        <ul>
            <?php   
                wp_list_comments( 
                    'type=comment&max_depth=5&callback=simple_comment_format'
                ); 
            ?>
        </ul>
    </section>
<?php endif; ?>

Everything is working ok except that the comment reply links are not showing up for any of the comments.
The documentation on modifying comments in general seems really bad!
Thanks for any help

1 Answer
1

You should try to replace

<?php comment_reply_link(); ?>

with:

<?php comment_reply_link( $args ); ?>

and to make sure the $args['depth'] is not zero or greater or equal than the $args['max depth']. There will be no output if that’s not the case.

If that doesn’t work, you could try to add the comment ID or the comment object as the second input parameter to comment_reply_link( $args, $comment ).

Also check if the comments are open.

Update:

If we look at the default callback, we see how the arguments of comment_reply_link() are constructed:

comment_reply_link( array_merge( $args, array(
    'add_below' => $add_below,
    'depth'     => $depth,
    'max_depth' => $args['max_depth'],
    'before'    => '<div class="reply">',
    'after'     => '</div>'
 ) ) );

where we can see how the depth and max_depth are included.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *