• I just added a Recent Posts block into single.php. Check it here under the body of the post…

    https://chronictriathlete.com/wordpress/race-report-2009-gretes-great-gallop

    It’s pulling in the right recent post content, but it’s screwing up the comments on the page. It’s causing the comments of every post to have the comments from the post that’s at the bottom of the Recent Posts list.

    I’ve narrowed the error down to somewhere in this code, but I hacked it out of a tutorial I found and don’t know PHP or WP well enough to sort it out.

    <div class="left">
        <h4 class="subtitle">Recent Posts</h4>
        <?php
        global $post;
        $cat=get_cat_ID('top-menu');
        $myposts2=get_posts(array('post__not_in'=>get_option('sticky_posts'),'cat'=>-$cat));
        foreach($myposts2 as $post) :
        ?>
        <div class="content">
            <div class="thumbnail"><a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true);?>" height="50" width="50" /></a></div>
            <div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
        </div>
        <?php endforeach; ?>
        <div class="footer"><a href="https://www.chronictriathlte.com/wordpress">See more posts &raquo;</a></div>
    </div>

    Any thoughts?
    /g

  • The topic ‘Recent Posts Blurb Messing Up My Comments’ is closed to new replies.