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.