How to combine these two queries? (3 posts)

  1. Benjamin_SP
    Posted 6 years ago #

    I have this query at the start of my index.php:

    <?php query_posts($query_string . '&cat=-5'); ?>

    It prevents displaying of posts from the category with the id "5" from showing in the homepage.

    I also have this query:

    <?php query_posts('showposts=6'); ?>

    It shows only 6 posts on the homepage (a number different from the one I chose under "Blog posts show at most" in Settings >> Reading. This is because I need 20 posts to show in my archive and category pages and only 6 on the homepage.

    Problem is, either one of these two tags work - not both. If I put both together everything falls apart. I don't get 6 posts and the pagination and everything breaks. Can these two queries be combined in any way to work together?

  2. tomontoast
    Posted 6 years ago #

    Of course try:
    <?php query_posts($query_string . '&cat=-5&showposts=6'); ?>

  3. Benjamin_SP
    Posted 6 years ago #

    Hey it worked, thanks man.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.