Forums

[resolved] Help with category exclude (3 posts)

  1. ThorHammer
    Member
    Posted 2 years ago #

    I need help to exclude two categories from appearing on my front page. I use this code in index.php:

    <?php
    if ($posts)
    {
      foreach($posts as $post)
    if (is_home() || is_front_page() ) {
          query_posts("cat=-32,-71");
       }
      {
    	start_wp();
    ?>

    But it doesn't work. The codex says it does, but it doesn't.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    The placement of query_posts is wrong. It should be before the start of the Loop.

    Try:

    <?php
    if (is_home() || is_front_page() ) {
          query_posts("cat=-32,-71");
       }
    if ($posts)
    {
      foreach($posts as $post)
      {
    	start_wp();
    ?>
  3. ThorHammer
    Member
    Posted 2 years ago #

    Thanks, I solved it by adding the exclude in functions.php :-)

Topic Closed

This topic has been closed to new replies.

About this Topic