Arve Systad
Member
Posted 3 years ago #
Hi, i'm having a tiny struggle with the query_posts() function.
query_posts('showposts=2'); while (have_posts()) : the_post(); ?> [post-content-stuff]
Works like a charm. When i add &cat=-19 to the query_posts parameter, it only returns the two very first posts ever to be posted, not the two last ones - which results in my front page showing over four year old posts.
Why is this? It seems to work just fine for everyone else wanting to exclude a category, so i must obviously be doing something wrong...
What version of MySQL is in use on your host?
Wonder what happens if you use the order=DESC parameter?
Resource: template tag, query_posts()
Arve Systad
Member
Posted 3 years ago #
My host runs MySQL 5, and the order=DESC (alone and along with orderby=date) has no effect. Also tried adding all the parameters as an array, with the same result. :\
Arve Systad
Member
Posted 3 years ago #
Ok, i did it the other way around. Stupid way to do it really, but since i'll probably never add more categories, so it's not a big issue.
cat=1,2,3,4,5.... - adding all, except the one i want to exclude worked. :)
Note, there is a known bug with MySQL 5.0.51 (and maybe other versions).
Should have pointed to this before:
http://wordpress.org/support/topic/154622
Arve Systad
Member
Posted 3 years ago #
Aah, I see. Well, then i know the reason why, so i'm pleased. Thanks a lot :)