Title: query_posts() broken in WordPress 2.5?
Last modified: August 19, 2016

---

# query_posts() broken in WordPress 2.5?

 *  [Jeffrey Barke](https://wordpress.org/support/users/jeffreyb/)
 * (@jeffreyb)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/)
 * Just finished upgrading two sites to WordPress 2.5 and everything went quite 
   smooth (or so I thought). On reviewing the site, I noticed that all templates
   where I used `query_posts` were broken.
 * This used to work:
    `query_posts('showposts=5&author=10');` `if (have_posts()):``
   while ($my_query->have_posts()):` `endwhile;` `endif;`
 * Now it doesn’t. I’ve been messing around with `$wp_query` and `WP_QUERY` all 
   morning, but no luck.
 * Any ideas? Is it my code? If so, what should I be doing?
 * Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Austin Matzko](https://wordpress.org/support/users/filosofo/)
 * (@filosofo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733531)
 * There is no global object in WordPress named `$my_query`, and there never has
   been.
 * Perhaps you used to do something like
 *     ```
       $my_query = query_posts('showposts=5&author=10');
       ```
   
 * That might make sense, but it seems unnecessary to perform the WP “Loop”.
 *  Thread Starter [Jeffrey Barke](https://wordpress.org/support/users/jeffreyb/)
 * (@jeffreyb)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733657)
 * Thanks filosofo; that’s my fault. Some of the code I posted earlier was wrong
   and I may not have been explicit enough about my problem.
 * Prior to upgrading from WordPress 2.0.9 to 2.5, the following page displayed 
   all the posts I’ve ever written. After the upgrade, it only shows five of my 
   posts.
    [http://themechanism.com/blog/author/jeffreybarke/](http://themechanism.com/blog/author/jeffreybarke/)
 * Here’s the actual code on the page:
 *     ```
       <?php
       query_posts('showposts=-1&author=' . $curauth->ID);
       if (have_posts()) : ?>
       <ul>
       <?php while (have_posts()): the_post(); ?>
       Some HTML output here
       <?php endwhile; ?>
       </ul>
       <?php endif; ?>
       ```
   
 * The code did not change, but its behavior did. Do you know why?
 * Thanks.
 *  [Austin Matzko](https://wordpress.org/support/users/filosofo/)
 * (@filosofo)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733667)
 * I don’t know why it doesn’t work for you; the same code for me works just fine.
 * You could either use the [`next_posts_link`](http://codex.wordpress.org/Template_Tags/next_posts_link)
   and `previous_posts_link` template tags within the while loop, to generate page
   links, or you could specify a really large number of posts to show instead of-
   1.
 *  Thread Starter [Jeffrey Barke](https://wordpress.org/support/users/jeffreyb/)
 * (@jeffreyb)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733693)
 * Unfortunately, none of the parameters work. `showposts=-1`, `showposts=1`, `showposts
   =5`, and `showposts=100` all return the same thing: five posts.
 * I’m going to test the `query_posts()` function on other blogs I’ve upgraded to
   2.5 and see if it works correctly there (I assume it will).
 * Thanks for the suggestions, though!
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733699)
 * > _Unfortunately, none of the parameters work. showposts=-1, showposts=1, showposts
   > =5, and showposts=100 all return the same thing: five posts._
 * Then I’d say that you have something else overriding it somewhere else, because
   query_posts() works fine for me.
 *  Thread Starter [Jeffrey Barke](https://wordpress.org/support/users/jeffreyb/)
 * (@jeffreyb)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733702)
 * You’re correct, Otto42. Sorry for the time, everyone, but thanks for looking 
   into this.
 * The problem was, of course, a plugin. Post-upgrade, I enabled the plugins one-
   by-one while refreshing the homepage; everything seemed to be working fine. I
   missed the fact that one of them messed with the query since no errors were thrown
   and the misbehavior is only evident on certain pages.
 * The plugin in question was Adhesive.
 * Thanks,
    Jeffrey
 *  [Dgold](https://wordpress.org/support/users/dgold/)
 * (@dgold)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733810)
 * WP 2.6 with the plugin WP-Sticky 1.31 (a plugin by Gamerz which replaces Adhesive),
   has the same negative effect of messing up my custom query_posts arguments.
 * In my case I had a page which was an alphabetical index of all my post titles.
   I have query_posts with orderby=title & sortposts=-1 (which means sort them alphabetically
   and show all)
 * I noticed it stopped working and researched several possibilities before I found
   this thread. This saved me some headache. Thanks.
 *  [warisover1981](https://wordpress.org/support/users/warisover1981/)
 * (@warisover1981)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733825)
 * try this, it works for me 🙂
    [http://weblogtoolscollection.com/archives/tag/query_posts/](http://weblogtoolscollection.com/archives/tag/query_posts/)
 *  [jberghem](https://wordpress.org/support/users/jberghem/)
 * (@jberghem)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733826)
 * Did you delete the wp-admin and wp-includes folders when you upgraded or did 
   you overwrite them?

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘query_posts() broken in WordPress 2.5?’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * 9 replies
 * 6 participants
 * Last reply from: [jberghem](https://wordpress.org/support/users/jberghem/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/query_posts-broken-in-wordpress-25/#post-733826)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
