Question

I've been following this tutorial and I can't manage to get my Reply working as intended with the wp_enqueue_script( 'comment-reply' ); php function.

I've removed code which I think is irrelevant for what I wish to accomplish.

Expected Output (Taken from Twenty Eleven 1.3 Minus stylesheets)

Expected output
(source: iforce.co.nz)

Actual Output (Taken from my theme Minus stylesheets)

Actual output
(source: iforce.co.nz)

How can I accomplish the Expected Output based off this tutorial for Advanced Comments? and what should I be doing with my functions.php and single.php to accomplish it?

Was it helpful?

Solution

The solution is actually pretty simple... after a little of reading the wordpress code for the javascript. I found the problem was in how each comment block was created.

based off this function in function.php

//this function will be called in the next section
function advanced_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; 
$PostAuthor = false;
if($comment->comment_author_email == get_the_author_email()) {
$PostAuthor = true;}
elseif($comment->comment_author_email == 'mordauk@gmail.com') {
$PostAuthor = true;} ?>
<li <?php if($PostAuthor) {echo "class='authorcomment' ";} ?>
<?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment, $size='48',$default='<path_to_url>' ); ?>
<div class="comment-meta"<a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a></div>
<small><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','') ?></small>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<div id="moderation"><?php _e('Your comment is awaiting moderation.') ?></div>
          <?php endif; ?><br />
        <div class="comment-text">  
          <?php comment_text() ?>
        </div>
          <div class="reply">
             <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'])), $comment->comment_ID) ?>
             <?php delete_comment_link(get_comment_ID()); ?>
          </div>
  <div class="clear"></div>
      <?php } ?>

I found the error was with

<?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

By simply removing the "li-" in the id so it forms id="comment-"

The reply form now moves on reply.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top