WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Multiple query_posts

[Resolved] Multiple query_posts

  • I have a theme where I’m listing the latest posts of a specific category in the header. But the problem I’ve run into is that when I use query_posts(‘showposts=1&cat=3’), the main Loop is also affected, and will only show one post of that category.

    Also affected are pages and categories which will show whatever query_posts got previously.

    Is there a workaround for this?

    What I’m essentially trying to do is post the latest post from a specific category, and the code for that comes before the main Loop which is supposed to list the latest posts overall. By using query_posts before the Main loop, it causes the main loop to also display what query posts called up.

    I’ve tried query_posts(‘showposts=10’) to no avail. It works fine for the home page, but when it comes to individual pages and categories, the posts it displays are the same.

Viewing 1 replies (of 1 total)
  • Moderator Samuel Wood (Otto)

    @otto42

    WordPress.org Tech Dude

    After you are finished with your extra query_posts, use this to reset it back to the defaults for whatever you’re supposed to be looking at:
    wp_reset_query();

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Multiple query_posts’ is closed to new replies.