Obviously, I know I can't have two single.php files. The one with the comments would have to have a different name...maybe single-comments.php or something.
I am working on a restaurant reviews site and because of lack of space on the page, I have decided to show some excerpts of the latest comments (customer reviews) on the side of the page and then create a link to all the other comments (customer reviews) and the comment form on another page. I have thought of lightboxes but I don't think it is ideal for what I want to achieve.
Any suggestions on how to get this done? Thanks.
EDIT: I created a page template for the comments and named it comments-side.php. Here is the code:
<?php
/*
* Template Name: Comments Page
*/
global $data; //get theme options
?>
<div id="comments-template">
<div class="comments-wrap">
<div id="comments">
<?php if ( have_comments() ) : ?>
<h3 id="comments-number" class="comments-header"><?php comments_number( __( 'No Comments', 'supreme' ), __( 'One Comment', 'supreme' ), __( '% Comments', 'supreme' ) ); ?></h3>
<?php do_atomic( 'before_comment_list' );// supreme_before_comment_list ?>
<?php if ( get_option( 'page_comments' ) ) : ?>
<div class="comment-navigation comment-pagination">
<span class="page-numbers"><?php printf( __( 'Page %1$s of %2$s', 'supreme' ), ( get_query_var( 'cpage' ) ? absint( get_query_var( 'cpage' ) ) : 1 ), get_comment_pages_count() ); ?></span>
<?php paginate_comments_links(); ?>
</div><!-- .comment-navigation -->
<?php endif; ?>
<ol class="comment-list">
<?php wp_list_comments( hybrid_list_comments_args() ); ?>
</ol><!-- .comment-list -->
<?php do_atomic( 'after_comment_list' ); // supreme_after_comment_list ?>
<?php endif; ?>
<?php if ( pings_open() && !comments_open() ) : ?>
<p class="comments-closed pings-open">
<?php printf( __( 'Comments are closed, but <a href="%1$s" title="Trackback URL for this post">trackbacks</a> and pingbacks are open.', 'supreme' ), get_trackback_url() ); ?>
</p><!-- .comments-closed .pings-open -->
<?php elseif ( !comments_open() ) : ?>
<p class="comments-closed">
<?php _e( 'Comments are closed.', 'supreme' ); ?>
</p><!-- .comments-closed -->
<?php endif; ?>
</div><!-- #comments -->
<?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array(
'author' => '<div class="form_row clearfix">' .
'<input id="author" name="author" type="text" value="' .
esc_attr( $commenter['comment_author'] ) . '" size="30"' . @$aria_req . ' PLACEHOLDER="'.__('Your name','supreme').'"/>' .
( $req ? ' <span class="required">*</span>' : '' ) .
'</div><!-- #form-section-author .form-section -->',
'email' => '<div class="form_row clearfix">' .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . @$aria_req . ' PLACEHOLDER="'.__('Email Address','supreme').'"/>' .
( $req ? ' <span class="required">*</span>' : '' ) .
'</div><!-- #form-section-email .form-section -->',
'url' => '<div class="form_row clearfix">' .
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30"' . @$aria_url . ' PLACEHOLDER="'.__('Website','supreme').'"/>'.'</div>')),
'comment_field' => '<div class="form_row clearfix">' .
'<textarea id="comments" name="comment" cols="45" rows="8" aria-required="true" PLACEHOLDER="'.__('Comments','supreme').'"></textarea>' .
( $req ? ' <span class="required">*</span>' : '' ) .
'</div><!-- #form-section-comment .form-section -->',
'comment_notes_after' => '',
'title_reply' => __( 'Add a comment', 'supreme' ),
);
if(get_option('default_comment_status') =='open'){
comment_form($comment_args); } // Loads the comment form. ?>
</div><!-- .comments-wrap -->
</div><!-- #comments-template -->
I created a page in Wordpress' admin and selected the comments page template for that page. This is what I have in functions.php to handle comments:
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','' );
?>
</div>
<?php comment_text($comment_ID); ?>
<a href="comments-side/#comment-<?php comment_ID() ?>" class="comment-more">read more</a>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
And this is how I am calling the comments in the side of single-restaurant.php
<div class="sidereviews clearfix">
<h3>Recent Reviews</h3>
<?php comments_template( '/comments-side.php', true ); // Loads the comments-side.php template. ?>
</div><!--/sidereviews-->
There is another comment file (comments.php) that handles comments on the blog. What should I change or get rid of? What am I doing wrong? Thanks.