WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Comments box not showing up on new posts -- why? (11 posts)

  1. problematic23
    Member
    Posted 5 years ago #

    Interesting issue: Someone helped me tweak my blog, located at x-entertainment.com/updates

    Mainly, he paged the comments using the simple feature built into WP.

    However, ever since then, when I post a new entry, the comments box is entirely missing. (But the comments on older entries still work fine.

    I can't for the life of me figure out why this is happening. Here is my comment and page PHPs.

    Comments.php file:

    <?php // Do not delete these lines
    if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    	die ('Please do not load this page directly. Thanks!');
    if ( post_password_required() ) {
    	echo '<p class="nocomments">This post is password protected. Enter the password to view comments.</p>';
    	return;
    }
    		/* This variable is for alternating comment background */
    		$oddcomment = 'alt';
    ?>
    
    <!-- You can start editing here. -->
    	<div align="center"><?php if ($comments) : ?><a name="comments"></a><BR /><span style="font-weight: bold; font-family: arial; font-size: 16px">Discussion Thread: <?php comments_number('no comments', '1 comment', '% comments' );?></div></span> <hr>
    <div style="text-align:center";>
    <?php paginate_comments_links(); ?>
    </div>
    	<?php if ( have_comments() ) : ?>
    
    <?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
    
    <div style="text-align:center";>
    <?php paginate_comments_links(); ?>
    </div>
    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ('open' == $post->comment_status) :
    		// If comments are open, but there are no comments.
    	else : // comments are closed
    	endif;
    endif;
    ?>
    
    <h3 id="respond">Add A New Comment!</h3>
    
    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    
    <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
    
    <?php else : ?>
    
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    
    <?php if ( $user_ID ) : ?>
    
    <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout</a>]</p>
    
    <?php else : ?>
    
    <!--<p><a href="http://x-entertainment.com/wordpress/wp-register.php" title="Register">Click Here To Register &raquo;</a></p>-->
    
    <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
    
    <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
    
    <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
    
    <label for="url"><small>Website</small></label></p>
    
    <?php endif; ?>
    
    <!--<p><small><strong>XHTML:</strong> You can use these tags: <?php echo allowed_tags(); ?></small></p>-->
    
    <p><textarea name="comment" id="comment" cols="58%" rows="8" tabindex="4"></textarea></p>
    
    <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    
    </p>
    
    <?php do_action('comment_form', $post->ID); ?>
    
    </form>
    
    <?php endif; // If registration required and not logged in ?>
    
    <?php endif; // if you delete this the sky will fall on your head ?>

    And my page.php:

    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div class="post" id="post-<?php the_ID(); ?>">
    
    		<h2><?php the_title(); ?></h2>
    
    			<div class="entry">
    
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    
    			</div>
    
    		</div>
    
    	  <?php endwhile; endif; ?>
    
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    
    	</div>
    
    <?php get_footer(); ?>

    Any thoughts would be greatly appreciated.

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Please don't post huge chunks of code here. For larger blocks of code, use the WordPress pastebin. It makes life easier for everyone.

    In the meantime, have a look in single.php for <?php comments_template();?>.

  3. problematic23
    Member
    Posted 5 years ago #

    Sorry about that.

    I have checked single.php and that code is within it.

    I have a feeling the code you posted is missing somewhere on another critical php file. Perhaps one that was edited to make the newly-paged comment organization look right. Would you or anyone have an idea which file I should be looking for to see that?

  4. alism
    Member
    Posted 5 years ago #

    Hi again! :-) Still no joy, eh?

    I've been been playing around on my test blog with that code. Try this...

    Find this part:

    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ('open' == $post->comment_status) :
    		// If comments are open, but there are no comments.
    	else : // comments are closed
    	endif;
    endif;
    ?>
    
    <h3 id="respond">Add A New Comment!</h3>

    ...and then change it to this:

    <?php else : // this is displayed if there are no comments so far ?>
    	<?php if ('open' == $post->comment_status) :
    		// If comments are open, but there are no comments.
    	else : // comments are closed
    	endif;
    endif;
    endif;
    ?>
    
    <?php if ( comments_open() ) : ?>
    
    <h3 id="respond">Add A New Comment!</h3>

    Let me know how you get on with that. Apologies in advance if it initiates thermonuclear war!!

  5. problematic23
    Member
    Posted 5 years ago #

    Oooh, thank you!

    But on which php should I be adding this? :)

  6. alism
    Member
    Posted 5 years ago #

    Find that first part of code in your comments.php and replace it with the second chunk.

  7. problematic23
    Member
    Posted 5 years ago #

    Oh my GOD!

    It worked, it worked!

    Thank you SO much -- I've bee sweating over this since Friday night!

  8. alism
    Member
    Posted 5 years ago #

    Hurrah! No problem matey. I hate being beaten by things like that! :-)

    (don't forget to turn the comments back on for that deadly dollar store post too by the way!!)

  9. problematic23
    Member
    Posted 5 years ago #

    Hahah, I think I'm going to leave that one closed, otherwise people will think it's some randomly unpopular article, and that'll drive me nuts. ;)

    I'd like to thank you in my next entry -- credit to alism? Any page you want me to link to or anything?

    Seriously, thanks again! Hopefully someone else who has this problem will see this message in the future!

  10. alism
    Member
    Posted 5 years ago #

    Ah, fair enough. Well if you want to add a link to my site: blog.alism.com I wouldn't want to stop you or anything!!

    ...and once again, you're quite welcome. :-)

  11. shatterjack
    Member
    Posted 5 years ago #

    hippievstony

    hey alism, any chance you might have an idea about why my comment field isn't showing up? as soon as I add the $withcomments=1 and comment_tempalte() I get "comments are closed" after each post. The comments themselves are outputting, but not the entry fields.

    <?php
    if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!');
    if (!empty($post->post_password)) { // if there's a password
    	if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
    ?>
    
    <h2><?php _e('Password Protected'); ?></h2>
    <p><?php _e('Enter the password to view comments.'); ?></p>
    
    <?php return;
    	}
    }
    
    $oddcomment = 'alt';
    
    ?>
    
    <?php if ($comments) : ?>
    	<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
    
    <ol class="commentlist">
    <?php foreach ($comments as $comment) : ?>
    
    	<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    
    <div class="commentmetadata">
    <strong><?php comment_author_link() ?></strong>, <?php _e('on'); ?> <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> <?php _e('at');?> <?php comment_time() ?></a> <?php _e('Said:'); ?> <?php edit_comment_link('Edit Comment','',''); ?>
     		<?php if ($comment->comment_approved == '0') : ?>
    		<em><?php _e('Your comment is awaiting moderation.'); ?></em>
     		<?php endif; ?>
    </div>
    
    <?php comment_text() ?>
    	</li>
    
    <?php /* Changes every other comment to a different class */
    	if ('alt' == $oddcomment) $oddcomment = '';
    	else $oddcomment = 'alt';
    ?>
    
    <?php endforeach; ?>
    	</ol>
    
    <?php else : ?>
    
    <?php if ('open' == $post->comment_status) : ?>
    	<!-- If comments are open, but there are no comments. -->
    	<?php else : // comments are closed ?>
    
    <p class="nocomments">Comments are closed.</p>
    
    	<?php endif; ?>
    <?php endif; ?>
    
    <?php if ('open' == $post->comment_status) : ?>
    
    		<h3 id="respond">Leave a Reply</h3>
    
    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
    
    <?php else : ?>
    
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    <?php if ( $user_ID ) : ?>
    
    <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout &raquo;</a></p>
    
    <?php else : ?>
    
    <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="40" tabindex="1" />
    <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="40" tabindex="2" />
    <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="40" tabindex="3" />
    <label for="url"><small>Website</small></label></p>
    
    <?php endif; ?>
    
    <!--<p><small><strong>XHTML:</strong> <?php _e('You can use these tags:'); ?> <?php echo allowed_tags(); ?></small></p>-->
    
    <p><textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea></p>
    
    <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    </p>
    
    <?php do_action('comment_form', $post->ID); ?>
    
    </form>
    
    <?php endif; ?>
    
    <?php endif; ?>

    sorry about the length but I was having a hard time with the paste bin for some reason...

Topic Closed

This topic has been closed to new replies.

About this Topic