ThemeShaper Forums » Thematic

[closed]

A custom loop before the comments is messing up the comments

(2 posts)
  • Started 3 years ago by rafi5749
  • Latest reply from rafi5749
  • This topic is resolved

Tags:

  1. rafi5749
    Member

    Hi there. A the bottom of a single post, I want to have some links to other posts from a category. So I put this loop in my childtheme_override_single_post() function right before calling thematic_belowpost():

    <?php $my_query = new WP_Query('category_name=essays&posts_per_page=5&order=DESC'); ?>

    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

    <?php $postid = get_the_ID(); if (!(is_single($postid))) { ?>

    <li><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php } ?>

    <?php endwhile; ?>

    I use the if to prevent the current post from appearing in the loop. The loop then works as I want it to.

    THE PROBLEM: When Thematic goes to publish the comments, it gets the comments belonging to the last post from my loop, not of the current single post! For example, at the bottom of the post about apples my loop will deliver posts on bananas and oranges, but then Thematic will present the comments on oranges instead of on apples.

    My loop is clearly overwriting a variable used to call the comments. I suspect that it's $post. How do I reset it?

    Posted 3 years ago #
  2. rafi5749
    Member

    Solved it! Just call wp_reset_query(); after the loop.

    Thank you for this forum, by the way. It's really gotten me far with Thematic.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.