Support » Fixing WordPress » query_posts() breaks comments_template()

  • Resolved Innovine


    I have included comments_template() in my Loop, as I want the front page of my blog to show all the recent comments. I’ve noticed however that if I add query_posts(‘showposts=10’); before the loop, the comments stop working (the add comment link just reloads the main page)

    This does not occur if I take the index.php code and use it in a page template…

    I havn’t really changed anything else from the default installation. Any suggestions for what is happening?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Aha!
    This seems to be fixed by using:
    <?php query_posts($query_string."&showposts=10"); ?>

    Just putting this here too as it’s relevant:

    I had this problem when creating a new template. I had used the sidebar before the index/single page which meant I used query_posts to pull out a specific selection of posts before the main loop runs.

    If you do your own custom query_posts make sure you do a wp_reset_query after then the comments will work properly.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘query_posts() breaks comments_template()’ is closed to new replies.