• Resolved intothewhite

    (@intothewhite)


    Hi – I’m finding that my posts are only displaying the most recent comment made on any post. For example, if I have a post with 3 comments on it, it will only display the most recent comment made on any post, even if it’s not the same post (see my blog for an example).

    My db is fine, and if I change theme the problem’s resolved. It’s therefore a problem with my theme.

    I think the problem resides in this bit of comments.php:

    <?php if ($comments) : ?>
    
    	<h3 id="comments"><?php comments_number('No response', 'One response', '% responses' );?> to “<?php the_title(); ?>”</h3>
    
    	<?php foreach ($comments as $comment) : ?>
    
    		<div class="commentmetadata">
    
    			<ul>
    
    				<li><span>Posted: </span><?php comment_date('d-m-y') ?></li>
    				<li><span>Written by: </span><?php comment_author_link() ?></li>
    
    			</ul>
    
    			<?php if ($comment->comment_approved == '0') : ?>
    				Your comment is awaiting moderation.
    
    			<?php endif; ?>
    
    		</div>
    
    		<div class="commenttext">
    
    			<?php comment_text() ?>
    
    		</div>
    
    	<?php /* Changes every other comment to a different class */
    		if ('alt' == $oddcomment) $oddcomment = '';
    		else $oddcomment = 'alt';
    	?>
    
    	<?php endforeach; /* end for each comment */ ?>

    Any help would be appreciated.

    Leon

Viewing 1 replies (of 1 total)
  • Thread Starter intothewhite

    (@intothewhite)

    I’ve looked into this some more and found that the problem is related to how I tag posts.

    If I tag a post with ‘lead’ it is displayed on the blog’s front page. I put this before the loop in index.php:

    <?php if (have_posts()) : ?>
    
    	<?php query_posts("tag=lead&showposts=1"); ?>
    
    	<?php while (have_posts()) : the_post(); ?>

    It appears that only comments made on the lead post will appear on any post’s single page. I can’t for the life of me figure out why this is the case.

    I’m not sure if it’s related, but I also use <? php query_posts(); ?> within the loop in my single.php file. Is it OK to use it within the loop?

    TIA,

    Leon

Viewing 1 replies (of 1 total)
  • The topic ‘Posts always show the most recent comment’ is closed to new replies.