Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$15
Enable Threaded Comments on Sandbox theme
I just am not sure what function or code I need to put in. I would like to have a reply button, display when you hover over the comment box - similar to http://uxbooth.com
You can view my site here... http://lab.inspiredology.com/holly-web-header-hell/#comments
Here is the current code for the comments page....
<div class="mainSplitter"> </div>
<div class="commentBox">
<?php
if ( 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']) ){
die ( 'Please do not load this page directly. Thanks.' );
}
?>
<div id="comments">
<?php
if ( !empty($post->post_password) ) {
if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) {
?>
<div class="nopassword"><?php _e( 'This post is protected. Enter the password to view any comments.', 'sandbox' ) ?></div>
<?php
}
}
?>
<?php if ( $comments ) { ?>
<?php global $sandbox_comment_alt ?>
<?php // Number of pings and comments
$ping_count = $comment_count = 0;
foreach ( $comments as $comment ){
get_comment_type() == "comment" ? ++$comment_count : ++$ping_count;
}
?>
<?php if ( $comment_count ) { ?>
<?php $sandbox_comment_alt = 0 ?>
<div id="comments-list" class="comments">
<h2>Join the discussion</h2>
<ul>
<?php foreach ($comments as $comment) { ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
<?php $i++ ; ?>
<li id="comm<?php comment_ID() ?>" class="<?php alternate_rows_author_comment($i, $comment, $post); ?>">
<div class="comment-author vcard"><?php echo get_avatar( $comment, 60 ); ?></div>
<div class="comment-name"><?php comment_author() ?></div>
<div class="comment-meta"><?php printf(__('%1$s at %2$s', 'sandbox'),
get_comment_date(),
get_comment_time(),
'#comment-' . get_comment_ID() );
edit_comment_link(__('', 'sandbox'), '', ''); ?>
</div>
<?php if ($comment->comment_approved == '0') {
_e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'sandbox');
} ?>
<?php comment_text() ?>
</li>
<?php } else { ?>
<?php $trackback = true; ?>
<?php } ?>
<?php } ?>
</ul>
</div>
<?php } ?>
<?php if ( $ping_count ) { ?>
<?php $sandbox_comment_alt = 0 ?>
<div id="trackbacks-list" class="trackbacks">
<h2 class="trigger"><a href="#"><?php printf($ping_count > 1 ? __('<span>%d</span> Trackbacks', 'sandbox') : __('<span>One</span> Trackback', 'sandbox'), $ping_count) ?></a></h2>
<div class="toggle_container">
<div class="block">
<ul>
<?php foreach ( $comments as $comment ) { ?>
<?php if ( get_comment_type() != "comment" ) { ?>
<!--POSSIBLE AUTHOR COMMENT STYLES-->
<li class="<?php if ($comment->user_id == 1) $oddcomment = "authorstyle"; echo $oddcomment; ?>">
<!--END POSSIBLE AUTHOR STYLES-->
<div class="comment-name"><?php printf(get_comment_author_link()) ; ?></div>
<div class="comment-meta"><?php printf(__('%1$s on %2$s', 'sandbox'),
get_comment_date(),
get_comment_time() );
edit_comment_link(__('', 'sandbox'), '', '</span>');
?>
</div>
<?php if ($comment->comment_approved == '0') {
_e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'sandbox');
}
?>
</li>
<?php } ?>
<?php } ?>
</ul>
</div>
</div>
</div>
<?php } ?>
<div class="clear"></div>
<?php } ?>
<?php if ( 'open' == $post->comment_status ) { ?>
<?php $req = get_option('require_name_email'); // Checks if fields are required. Thanks, Adam. ;-) ?>
<div id="respond">
<h2><?php _e( 'Post a Comment', 'sandbox' ) ?></h2>
<?php if ( get_option('comment_registration') && !$user_ID ) { ?>
<p id="login-req">
<?php printf(__('You must be <a href="%s" title="Log in">logged in</a> to post a comment.', 'sandbox'),
get_bloginfo('wpurl') . '/wp-login.php?redirect_to=' . get_permalink() ) ?>
</p>
<?php } else { ?>
<div class="formcontainer">
<form id="commentform" action="<?php bloginfo('wpurl') ?>/wp-comments-post.php" method="post">
<?php if ( $user_ID ) { ?>
<p id="login"><?php
printf( __( '<span class="loggedin">Logged in as <a href="%1$s" title="Logged in as %2$s">%2$s</a>.</span> <span class="logout"><a href="%3$s" title="Log out of this account">Log out?</a></span>', 'sandbox' ),
get_bloginfo('wpurl') . '/wp-admin/profile.php',
wp_specialchars( $user_identity, 1 ),
get_bloginfo('wpurl') . '/wp-login.php?action=logout&redirect_to=' . get_permalink() );
?>
</p>
<?php } else { ?>
<p id="comment-notes"><?php _e( 'Your email is never shared.', 'sandbox' ) ?> <?php if ($req) _e( 'Required fields are marked <span class="required">*</span>', 'sandbox' ) ?></p>
<div class="form-label"><label for="author"><?php _e( 'Name', 'sandbox' ) ?></label> <?php if ($req) _e( '<span class="required">*</span>', 'sandbox' ) ?></div>
<div class="form-input"><input id="author" name="author" class="text<?php if ($req) echo ' required'; ?>" type="text" value="<?php echo $comment_author ?>" size="30" maxlength="50" tabindex="3" /></div>
<div class="form-label"><label for="email"><?php _e( 'Email', 'sandbox' ) ?></label> <?php if ($req) _e( '<span class="required">*</span>', 'sandbox' ) ?></div>
<div class="form-input"><input id="email" name="email" class="text<?php if ($req) echo ' required'; ?>" type="text" value="<?php echo $comment_author_email ?>" size="30" maxlength="50" tabindex="4" /></div>
<div class="form-label"><label for="url"><?php _e( 'Website', 'sandbox' ) ?></label></div>
<div class="form-input"><input id="url" name="url" class="text" type="text" value="<?php echo $comment_author_url ?>" size="30" maxlength="50" tabindex="5" /></div>
<?php } ?>
<div class="form-label"><label for="comment"><?php _e( 'Comment', 'sandbox' ) ?></label></div>
<div class="form-textarea"><textarea id="comment" name="comment" class="text required" cols="45" rows="8" tabindex="6"></textarea></div>
<div class="form-submit"><input id="submit" name="submit" class="button" type="submit" value="<?php _e( '', 'sandbox' ) ?>" tabindex="7" /><input type="hidden" name="comment_post_ID" value="<?php echo $id ?>" /></div>
<div class="form-option"><?php do_action( 'comment_form', $post->ID ) ?></div>
</form><!-- #commentform -->
</div><!-- .formcontainer -->
<?php } ?>
</div>
<?php } ?>
</div> <!-- #comments /-->
</div> <!-- .commentBox /-->
<?php include ('sidebar-comment.php'); ?>
<div class="clear"></div>
<div class="mainSplitter_rev"> </div>
This question has been answered.
Chad Mueller | 06/12/10 at 7:01am
Edit
(2) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
06/12/10
8:23amBill Hunt says:I don't think you need to change any of the comments.php code for this. Threaded comments are a little tricky, you'd do best to use one of the many plugins available. This article will get you started on modifying your template, but also has a list of plugins that will do the same thing:
http://idratherbewriting.com/2009/05/31/wordpresss-threaded-comments/
-

Last edited:
06/18/10
8:34amBrian Richards says:Chad, I encountered this exact problem almost a year ago. My own framework is forked from Sandbox, let me fetch the code for you!
Quick answer while I patch it in to what you have: you need to use function wp_list_comments to handle the comment loop for you, and wrap your comment format in a function that is referenced by wp_list_comments. Same is true for trackbacks.
Here is your new code:
<div class="mainSplitter"> </div>
<div class="commentBox">
<?php
if ( 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']) )
die ( 'Please do not load this page directly. Thanks.' );
?>
<div id="comments">
<?php
if ( post_password_required() ) { ?>
<div class="nopassword"><?php _e( 'This post is protected. Enter the password to view any comments.', 'sandbox' ) ?></div>
</div><!-- .comments -->
<?php return; } ?>
<?php if ( have_comments() ) : ?>
<?php // Number of pings and comments
$ping_count = $comment_count = 0;
foreach ( $comments as $comment )
get_comment_type() == "comment" ? ++$comment_count : ++$ping_count;
if ( ! empty($comments_by_type['comment']) ) : ?>
<div id="comments-list" class="comments">
<h2>Join the Discussion</h2>
<ol class="commentlist">
<?php wp_list_comments('type=comment&callback=sandbox_comment'); ?>
</ol>
<div id="comments-nav-below" class="comment-navigation">
<div class="paginated-comments-links"><?php paginate_comments_links(); ?></div>
</div>
</div><!-- #comments-list .comments -->
<div class="cb"></div>
<?php endif; // REFERENCE: if ( $comment_count ) ?>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<div id="trackbacks-list" class="comments">
<h2 class="trigger"><a href="#"><?php printf($ping_count > 1 ? __('<span>%d</span> Trackbacks', 'sandbox') : __('<span>One</span> Trackback', 'sandbox'), $ping_count) ?></a></h2>
<div class="toggle_container">
<div class="block">
<ul>
<?php wp_list_comments('type=pings&callback=sandbox_ping'); ?>
</ul>
</div>
</div>
</div><!-- #trackbacks-list .comments -->
<?php endif // REFERENCE: if ( $ping_count ) ?>
<?php endif // REFERENCE: if ( have_comments ) ?>
<div class="clear"></div>
<?php if ( 'open' == $post->comment_status ) { ?>
<?php $req = get_option('require_name_email'); // Checks if fields are required. Thanks, Adam. ;-) ?>
<div id="respond">
<h2><?php _e( 'Post a Comment', 'sandbox' ) ?></h2>
<?php if ( get_option('comment_registration') && !$user_ID ) { ?>
<p id="login-req">
<?php printf(__('You must be <a href="%s" title="Log in">logged in</a> to post a comment.', 'sandbox'),
get_bloginfo('wpurl') . '/wp-login.php?redirect_to=' . get_permalink() ) ?>
</p>
<?php } else { ?>
<div class="formcontainer">
<form id="commentform" action="<?php bloginfo('wpurl') ?>/wp-comments-post.php" method="post">
<?php if ( $user_ID ) { ?>
<p id="login"><?php
printf( __( '<span class="loggedin">Logged in as <a href="%1$s" title="Logged in as %2$s">%2$s</a>.</span> <span class="logout"><a href="%3$s" title="Log out of this account">Log out?</a></span>', 'sandbox' ),
get_bloginfo('wpurl') . '/wp-admin/profile.php',
wp_specialchars( $user_identity, 1 ),
get_bloginfo('wpurl') . '/wp-login.php?action=logout&redirect_to=' . get_permalink() );
?>
</p>
<?php } else { ?>
<p id="comment-notes"><?php _e( 'Your email is never shared.', 'sandbox' ) ?> <?php if ($req) _e( 'Required fields are marked <span class="required">*</span>', 'sandbox' ) ?></p>
<div class="form-label"><label for="author"><?php _e( 'Name', 'sandbox' ) ?></label> <?php if ($req) _e( '<span class="required">*</span>', 'sandbox' ) ?></div>
<div class="form-input"><input id="author" name="author" class="text<?php if ($req) echo ' required'; ?>" type="text" value="<?php echo $comment_author ?>" size="30" maxlength="50" tabindex="3" /></div>
<div class="form-label"><label for="email"><?php _e( 'Email', 'sandbox' ) ?></label> <?php if ($req) _e( '<span class="required">*</span>', 'sandbox' ) ?></div>
<div class="form-input"><input id="email" name="email" class="text<?php if ($req) echo ' required'; ?>" type="text" value="<?php echo $comment_author_email ?>" size="30" maxlength="50" tabindex="4" /></div>
<div class="form-label"><label for="url"><?php _e( 'Website', 'sandbox' ) ?></label></div>
<div class="form-input"><input id="url" name="url" class="text" type="text" value="<?php echo $comment_author_url ?>" size="30" maxlength="50" tabindex="5" /></div>
<?php } ?>
<div class="form-label"><label for="comment"><?php _e( 'Comment', 'sandbox' ) ?></label></div>
<div class="form-textarea"><textarea id="comment" name="comment" class="text required" cols="45" rows="8" tabindex="6"></textarea></div>
<div class="form-submit"><input id="submit" name="submit" class="button" type="submit" value="<?php _e( '', 'sandbox' ) ?>" tabindex="7" /><input type="hidden" name="comment_post_ID" value="<?php echo $id ?>" /></div>
<div class="form-option"><?php do_action( 'comment_form', $post->ID ) ?></div>
</form><!-- #commentform -->
</div><!-- .formcontainer -->
<?php } ?>
</div>
<?php } ?>
</div> <!-- #comments /-->
</div> <!-- .commentBox /-->
<?php include ('sidebar-comment.php'); ?>
<div class="clear"></div>
<div class="mainSplitter_rev"> </div>
<?php global $sandbox_comment_alt; ?>
<?php $sandbox_comment_alt = 0; ?>
<?php function sandbox_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
$GLOBALS['comment_depth'] = $depth;
$i++;
?>
<li>
<div class="comment-author vcard"><?php echo get_avatar( $comment, 60 ); ?></div>
<div class="comment-name"><?php comment_author() ?></div>
<div class="comment-meta">
<?php // echo the comment reply link with help from Justin Tadlock http://justintadlock.com/ and Will Norris http://willnorris.com/
if($args['type'] == 'all' || get_comment_type() == 'comment') :
comment_reply_link(array_merge($args, array(
'reply_text' => __('Reply to this Comment','sandbox'),
'login_text' => __('Log in to reply.','sandbox'),
'depth' => $depth,
'before' => '<span class="comment-reply-link">',
'after' => '</span>'
)));
endif;
?>
<?php printf(__('%1$s at %2$s', 'sandbox'),
get_comment_date(),
get_comment_time(),
'#comment-' . get_comment_ID() );
edit_comment_link(__('', 'sandbox'), '', ''); ?>
</div>
<?php if ($comment->comment_approved == '0') {
_e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'sandbox');
} ?>
<?php comment_text() ?>
</li>
<?php } ?>
<?php function sandbox_ping($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<?php $sandbox_comment_alt = 0 ?>
<li>
<div class="comment-name"><?php printf(get_comment_author_link()) ; ?></div>
<div class="comment-meta"><?php printf(__('%1$s on %2$s', 'sandbox'),
get_comment_date(),
get_comment_time() );
edit_comment_link(__('', 'sandbox'), '', '</span>');
?>
</div>
<?php if ($comment->comment_approved == '0') {
_e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'sandbox');
}
?>
</li>
<?php } ?>
The two new functions at the end, sandbox_comment and sandbox_ping, could actually be anywhere (like functions.php, for instance). These are the callbacks that get referenced in your comment and trackback loops.Previous versions of this answer: 06/12/10 at 9:23am | 06/12/10 at 10:18am
- 06/12/10 10:39am
Chad Mueller says:That seemed to break everything - the comment's didn't show up at all...
- 06/12/10 1:26pm
Brian Richards says:Can you send me the rest of your theme? It's working for me. brian @ rzen.net
Actually, the newest version sandbox has this functionality included.
- 06/12/10 10:39am
This question has expired.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
