Support » Fixing WordPress » Cannot exclude category from query_posts()

  • joesmalley

    (@joesmalley)


    A recent upgrade of WordPress has stopped some code from working on my index.php template. The code is used to hide all category 56 posts from appearing in my template’s loop:

    global $query_string;
    query_posts($query_string.'&cat=-56');

    However after a recent upgrade, it shows the posts from category 56. If I remove the $query_string from the query_post argument, it works, category 56 posts aren’t shown. So there’s some problem with what $query_string contains.

    If I echo out $query_string it returns ‘pagename=blog’.

Viewing 1 replies (of 1 total)
  • joesmalley

    (@joesmalley)

    I found a way around this by adding

    $query_string = remove_query_arg('pagename');

    between the two lines above. But I think there’s definitely a bug here, the pagename and cat parameters aren’t working together as they used to.

Viewing 1 replies (of 1 total)
  • The topic ‘Cannot exclude category from query_posts()’ is closed to new replies.