• Hi all!

    Does anyone know of a way to use the threaded/nested comments reply function but then maintaining a completely chronological (i.e. classic) order of comments?

    You know, like at boingboing.net, where you can still reply directly to other people but your comment shows up at the bottom, with a little link to the comment you replied to.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter CounterDax

    (@counterdax)

    Well, one way I might do it is by creating an array of all the comments based upon ‘date’=>’formatted comment’, resorting the array based on the date (timestamp) and then outputting everything in my custom comment formatting function. However, my concern is that this might be quite processing intensive (especially with many comments, CPU and bandwidth resources rise) so I was hoping there’s a better way to pull this off.

    Anyone?

    Thread Starter CounterDax

    (@counterdax)

    I’ll just keep documenting what I’ve discovered, just in case someone else needs some help with this too…

    The nested comments require a function that inserts two hidden input fields for the comment form to parse. When nested comments are turned off, or not supported in the comments template, these variables are still parsed and handled when submitting a comment. So, create a template lacking nested comments, add these two fields manually to the comment form, add WordPress’ nested comment handling javascript and the reply links manually too, and everything works. You’re still required to add the other necessities for nested comments, such as keeping the div id’s the same, adding the cancel link, etc.

    Add the following to the comment form:

    <input name="comment_post_ID" value="<?php echo $post->ID; ?>" id="comment_post_ID" type="hidden">
    <input name="comment_parent" id="comment_parent" value="0" type="hidden">

    Either use WordPress’ queue script function (along with wp_head()) as follows:
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    Or add the script manually to the head or just below the end of the body:
    <script type="text/javascript" src="<?php echo get_option('siteurl'); ?>/wp-includes/js/comment-reply.js"></script>

    Manually add the reply link to the comments:
    <a class="comment-reply-link" href="?replytocom=<?php comment_ID(); ?>#respond" onclick="return addComment.moveForm('comment-<?php comment_ID(); ?>', '<?php comment_ID(); ?>', 'respond', '<?php echo $post->ID; ?>')">reply</a>

    Now to show that a comment is a reply to a previous comment:

    <?php
    if ( $comment->comment_parent ) {
    	$parent = get_comment( $comment->comment_parent );
    	$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
    	printf( ' in reply to <a href="%1$s">%2$s</a>', $parent_link, $parent->comment_author );
    } ?>

    What’s next:
    This is quite a cumbersome way to manage all this, and I think there’s probably an easier way to pull boing-boing style non-nested nested comments off.
    The “in reply to” link now jumps the user to the original comments, lacking a link back to the comment reply. I’m now working on some simple javascript to show a ‘return to reply’ link.

    Really would like to implement this type of comments. I have tried to implement your code but failed to accomplish the described result. Where should I place the code? In the comments.php or the comment-template.php?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘"Reply to" link for chronological (non-threaded) comments’ is closed to new replies.