WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Threaded comments do not show up in correct order (7 posts)

  1. zephyrcat
    Member
    Posted 4 years ago #

    I have followed all the instructions on this page to get threaded comments to work:

    http://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display

    The comment reply box now correctly moves to the parent comment, however when a comment is left in reply to another comment, it shows up at the end of the comment list, not under the parent comment.

    I have also noticed that the threaded comment has class depth-1, not depth-2.

    What am I missing?

    my comments.php:

    <?php //arguments for wp_list_comments
    
    $commentargs = array(
       $style = 'ol'
    );
    
    ?>
    
    <div class="comments">
       <h4 id="commentshead"><?php comments_number('No comments on this post so far.', '1 comment on this post.', '% comments on this post.' );?></h4>
       <?php if ( have_comments() ) : ?>
          <ol class="commentlist">
             <?php wp_list_comments($commentargs); ?>
          </ol>
          <div class="navigation">
             <div class="alignleft"><?php previous_comments_link() ?></div>
             <div class="alignright"><?php next_comments_link() ?></div>
          </div>
       <?php else : // this is displayed if there are no comments so far ?>
             <?php if ( comments_open() ) : ?>
                <p class="leavefirst">Be the first to leave a comment!</p>
             <?php else : // comments are closed ?>
                <p class="commentsclosed">Comments are closed on this post. Sorry.</p>
             <?php endif; ?>
       <?php endif; ?>
    </div>
    
    <?php if ( comments_open() ) : ?>
       <div id="respond">
          <h4><?php comment_form_title( 'Leave a Comment', 'Leave a Reply to %s' ); ?></h4>
    
          <div class="cancel-comment-reply">
             <small><?php cancel_comment_reply_link(); ?></small>
          </div>
    
          <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
          <p>You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in</a> to post a comment.</p>
          <?php else : ?>
    
          <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
          <?php comment_id_fields(); ?>
    
          <?php if ( is_user_logged_in() ) : ?>
    
          <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p>
    
          <?php else : ?>
    
          <p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
          <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
    
          <p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
          <label for="email"><small>Email (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
    
          <p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
          <label for="url"><small>Website URL</small></label></p>
    
          <?php endif; ?>
    
          <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
    
          <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
    
          <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
          <?php comment_id_fields(); ?>
          </p>
          <?php do_action('comment_form', $post->ID); ?>
    
          </form>
    
          <?php endif; // If registration required and not logged in ?>
       </div>
    <?php endif; // if you delete this the sky will fall on your head ?>
  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Check that you have included the line <?php if(is_singular()) wp_enqueue_script( 'comment-reply' );?> in the <head></head section of your header.php file.

  3. zephyrcat
    Member
    Posted 4 years ago #

    esmi - Yes, I have that right after the <head> tag.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Try moving it down so that it is just before:

    <?php wp_head(); ?>
    </head>
  5. zephyrcat
    Member
    Posted 4 years ago #

    Still no luck.

  6. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Just spotted something in your code - right at the top:

    $commentargs = array(
       $style = 'ol'
    );

    Shouldn't that be:

    $commentargs = array(
       'style' => 'ol'
    );
  7. zephyrcat
    Member
    Posted 4 years ago #

    Well that mostly fixed it. Everything works now, except the comment box doesn't move. That's fine, though.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic