• I want to exclude all posts from category 3 from my blog. They just shouldn’t appear there.
    So I looked into the Codex and there it says:

    Placing this code in index.php file will cause the home page to display posts from all categories except category ID 3.

    <?php
    if ( is_home() ) {
    	query_posts( 'cat=-3' );
    }
    ?>

    (see here)

    I did just as this says and placed the code in my index.php file. And, well, there are no more posts from category 3 displayed. Unfortunately though there are also always just the same three posts displayed no matter how many pages I go back… “url.com/blog” shows just the three latest posts excluding anything from cat 3 but “url.com/blogpage/2/”, “url.com/blogpage/3/” and “url.com/blogpage/4/” show exactely the same posts…

    Does anybody know how to solve this? So that category 3 is excluded AND pagination works?

Viewing 1 replies (of 1 total)
  • That same article shows how to preserve existing query arguments.

    Give this a try:

    <?php
    if ( is_home() ) {
    	global $query_string;
    	query_posts($query_string . '&cat=-3' );
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Excluding posts from a specific category from the blog’ is closed to new replies.