desbest
desbest

Reputation: 4896

Trying to edit Hemingway wordpress theme to add "comment reply" link

I'm trying to edit the Hemingway theme by adding comment_reply_link() and when I print it in my theme, when I load up my website, the "reply" link doesn't appear.

Below is my code.

<?php if ($comments) : ?>

    <ol id="comments" class="commentlist">

    <?php foreach ($comments as $comment) : ?>
        <li id="comment-<?php comment_ID() ?>">
            <cite>
                        <span class="avatarspan"><?php echo get_avatar( $comment, 32 ); ?></span>
                <span class="author"><?php comment_author_link() ?></span>
                <span class="date"><?php comment_date('d/m/y') ?> / <?php comment_date('ga') ?></span>
            </cite>
            <div class="content">
                <?php if ($comment->comment_approved == '0') : ?>
                <em>Your comment is awaiting moderation.</em>
                <?php endif; ?>
                <?php comment_text() ?>
                <br><?php comment_reply_link(); ?>
            </div>
            <div class="clear"></div>
        </li>


    <?php /* Changes every other comment to a different class */    
        if ('alt' == $oddcomment) $oddcomment = '';
        else $oddcomment = 'alt';
    ?>

    <?php endforeach; /* end for each comment */ ?>

    </ol>

Why doesn't the link appear?

Upvotes: 0

Views: 33

Answers (1)

suspectus
suspectus

Reputation: 17268

Your code looks fine but I think it lacks the $args (specifically values for comment depth) parameter.

// get max_depth from options
$max_depth = get_option('thread_comments_depth');

// check it has sensible value
if (!$max_depth)
    $max_depth = 1;

?php comment_reply_link($args = array(
    'depth'      => 1,
    'max_depth'  => $max_depth
    ) 
   ); ?>

Upvotes: 2

Related Questions