• Hello – hoping someone might be able to help here. I’ve searched google and I can’t find the solution to my problem.

    I want to exclude a category from my homepage. I’ve got that working but the problem is it’s ordering it wrong. I looked through the codex to find how to order it but its just not working!
    query_posts ($query_string.'&cat=-19&orderby=date&order=DESC');

    I think this is correct as when I remove “&cat=-19” I can order the page using DESC or ASC but as soon as I choose to exclude cat 19 it won’t work and puts the old posts at the top.

    I even tried a plugin called “Simply Exclude” but it still won’t order it correctly after I’ve excluded the category.

    Anyone come across this problem – is it a WordPress bug?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Have you tried printing out $wp_query to see what query parameters WordPress is using?

    Add something like the following to your code, save, and then view source.

    <?php query_posts ($query_string.'&cat=-19&orderby=date&order=DESC'); ?>
    <!-- wp_query = <?php print_r($wp_query); ?> -->

    Thread Starter Moofin

    (@moofin)

    Hi Jkovis – thanks for taking the time to reply!

    I tried your suggestion and this is what it sent out:

    [cat] => -19
                [orderby] => wp_posts.post_date DESC
                [order] => DESC
                [error] =>
                [m] => 0
                [p] => 0
                [post_parent] =>
                [subpost] =>
                [subpost_id] =>
                [attachment] =>
                [attachment_id] => 0
                [name] =>
                [static] =>
                [pagename] =>
                [page_id] => 0
                [second] =>
                [minute] =>
                [hour] =>
                [day] => 0
                [monthnum] => 0
                [year] => 0
                [w] => 0
                [category_name] =>
                [tag] =>
                [tag_id] =>
                [author_name] =>
                [feed] =>
                [tb] =>
                [paged] => 0
                [comments_popup] =>
                [meta_key] =>
                [meta_value] =>
                [preview] =>
                [s] =>
                [sentence] =>
                [fields] =>
                [category__in] => Array

    There was more but this was the bulk of it. Interestingly enough when I uploaded it to a live server (I was working locally before) the order was working correctly. I’m still not sure why it doesn’t work locally as I see no reason for it to be any different.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude category from loop problems’ is closed to new replies.