WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] excluded categories? (6 posts)

  1. minushka
    Member
    Posted 6 years ago #

    I've been trying a number of plugins and coding to exclude one category from my frontpage, but nothing seems to work. Either nothing happens, or the entire site goes beserk. Anyone know something that actually does work?

  2. Adam Brown
    Member
    Posted 6 years ago #

    Have you played with query_posts?

    Something like this in your index.php would put a different set of posts on the front page as elsewhere:

    <?php
    if (is_home()){
      query_posts( ... put something here ... );
    }
    ?>
  3. Adam Brown
    Member
    Posted 6 years ago #

  4. minushka
    Member
    Posted 6 years ago #

    adamrbrown, I'm not sure I understand what you want me to put there...

    And I tried that plugin. Nothing happened :S

  5. ehab
    Member
    Posted 6 years ago #

    If you want to exclude some catagories in your home page then use the following code

    <?php
       if (is_home()) {
          query_posts("cat=-1,-2,-3");
       }
    ?>

    is_home = checks if it is your home page

    query_posts = searches the database for the given parametres. which is to exclude categories, 1,2,3

    Please go here and read the whole page for better love.

  6. minushka
    Member
    Posted 6 years ago #

    I read that section too, and tried, but it doesn't say where in the index to put the code, I must have put it wrong because it messed up a whole lot :P

Topic Closed

This topic has been closed to new replies.

About this Topic