thanks Fingli. I rearranged it and it is working great, but now whenever I unselect the "show comments" section of the page it appears anyway. I can't have this at all. How do I get this working? Here is my code:
<?php
/**
* Template: Comments.php
*
* @package WPFramework
* @subpackage Template
*/
// Make sure comments.php doesn't get loaded directly
if ( !empty( $_SERVER[ 'SCRIPT_FILENAME' ] ) && 'comments.php' == basename( $_SERVER[ 'SCRIPT_FILENAME' ] ) )
die ( 'Please do not load this page directly. Thanks!' );
if ( post_password_required() ) { ?>
<p class="password-protected alert">This post is password protected. Enter the password to view comments.</p>
<?php return; } ?>
<!--BEGIN #respond-->
<div id="respond">
<div class="cancel-comment-reply"><?php cancel_comment_reply_link( 'Cancel Reply' ); ?></div>
<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
<p id="login-req" class="alert">You must be /wp-login.php?redirect_to=<?php echo urlencode( get_permalink() ); ?>">logged in to post a comment.</p>
<?php else : ?>
<!--BEGIN #comment-form-->
<form id="comment-form" method="post" action="<?php echo get_option( 'siteurl' ); ?>/wp-comments-post.php">
<div id="comform">
<h3 id="leave-a-reply"><img class="postpimg" src="http://pcast.jeremypiersongraphics.com/bubble.jpg" width="40px" height="35px" /><?php comment_form_title( 'POST A PRAYER', 'Post a Prayer to %s' ); ?></h3> <?php if ( is_user_logged_in() ) : global $current_user; // If user is logged-in, then show them their identity ?>
<p class="loggedin">Logged in as /wp-admin/profile.php"><?php echo $user_identity; ?>. " title="Log out of this account">Log out »</p>
<!--BEGIN #form-section-author-->
<div id="form-section-author" class="form-section">
<input name="author" id="author" type="text" value="<?php echo $current_user->user_nicename; ?>" tabindex="1" <?php if ( $req ) echo "aria-required='true'"; ?> />
<label for="author"<?php if ( $req ) echo ' class="required"'; ?>>Name</label>
<!--END #form-section-author-->
</div>
<?php else : // If user isn't logged-in, ask them for their details ?>
<!--BEGIN #form-section-author-->
<div id="form-section-author" class="form-section">
<input name="author" id="author" type="text" value="<?php echo $comment_author; ?>" tabindex="1" <?php if ( $req ) echo "aria-required='true'"; ?> />
<label for="author"<?php if ( $req ) echo ' class="required"'; ?>>Name</label>
<!--END #form-section-author-->
</div>
<?php endif; // if ( is_user_logged_in() ) ?>
<!--BEGIN #form-section-comment-->
<div id="form-section-comment" class="form-section">
<textarea name="comment" id="comment" class="inputtext" tabindex="4"></textarea>
<!--END #form-section-comment-->
</div>
<!--BEGIN #form-section-actions-->
<div id="form-section-actions" class="form-section">
<button name="submit" id="submit" type="submit" tabindex="5">Submit Prayer</button>
<?php comment_id_fields(); ?>
<!--END #form-section-actions-->
</div>
</div>
<?php do_action( 'comment_form', $post->ID ); // Available action: comment_form ?>
<!--END #comment-form-->
</form>
<?php endif; // If registration required and not logged in ?>
<!--END #respond-->
</div>
<?php if ( have_comments() ) : // If comments exist for this entry, continue ?>
<!--BEGIN #comments-->
<div id="comments">
<?php if ( ! empty( $comments_by_type['comment'] ) ) { ?>
<?php framework_discussion_title( 'comment' ); ?>
<?php framework_discussion_rss(); ?>
<!--BEGIN .comment-list-->
<ol class="comment-list">
<?php wp_list_comments(array(
'type' => 'comment',
'callback' => 'framework_comments_callback',
'end-callback' => 'framework_comments_endcallback' )); ?>
<!--END .comment-list-->
<?php } ?>
<?php if ( ! empty( $comments_by_type['pings'] ) ) { ?>
<?php framework_discussion_title( 'pings' ); ?>
<!--BEGIN .pings-list-->
<ol class="pings-list">
<?php wp_list_comments(array(
'type' => 'pings',
'callback' => 'framework_pings_callback',
'end-callback' => 'framework_pings_endcallback' )); ?>
<!--END .pings-list-->
<?php } ?>
<!--END #comments-->
</div>
<?php endif; // ( have_comments() ) ?>
<?php if ( comments_open() ) : // show comment form ?>
<?php endif; // ( comments_open() ) ?>