WordPress.org

Ready to get started?Download WordPress

Forums

Ignore certain categories in Loop - Posts not in order!! (4 posts)

  1. danharper
    Member
    Posted 5 years ago #

    I'm trying to get my WordPress theme to retrieve all posts, except ones in a certain category. I'm using the following code:
    query_posts('orderby=post_date&order=desc&cat=-7');

    While this does successfully remove all posts from category 7, the posts do not display in order. They seem to show in a random order.
    I initially thought maybe it was a glitch in 2.5; but I've updated to 2.6, and same thing!

    How can I fix this? I'm going crazy over it!

  2. moshu
    Member
    Posted 5 years ago #

    Maybe reading carefully the documentationhelps:
    Template_Tags/query_posts#Orderby_Parameters

  3. danharper
    Member
    Posted 5 years ago #

    No, that doesn't work. BTW, when I put orderby=post_date, I meant to put orderby_date.

    I've also tried
    query_posts(array('category__not_in'=>array(7),'showposts'=>10,'orderby'=>'date','order'=>DESC));
    Which is code I got from the Codex, and isn't working.

  4. danharper
    Member
    Posted 5 years ago #

    Hey, sorry for the double-post; but I really need help with this! If someone can help, it'd be greatly appreciated.

    The only thing I can think of, is that I'm running the site on a Windows test server; but unless Apache/SQL on Windows somehow interprets things differently, that's just stupid!

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic