How to have homepage setup?

Discussion in 'WordPress' started by MakeThatDollar, Jun 5, 2008.

  1. #1
    How can I have the homepage of my blow only show posts from a certain category?
     
    MakeThatDollar, Jun 5, 2008 IP
  2. golddragon

    golddragon Active Member

    Messages:
    583
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I'm not sure, but you can take a look here
     
    golddragon, Jun 5, 2008 IP
  3. susan8051

    susan8051 Peon

    Messages:
    1,358
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just edit your index.php in your theme directory..

    Find the following code there

    <?php if (have_posts()) : ?>
    Code (markup):
    and immediately after that place the following
    <?php
     
       if (is_home()) {
     
          query_posts('category_name=News');
     
       }
     
    ?> 
    Code (markup):
    This will show all posts from the Category News on the home page..

    If you want to show posts from multiple categories on homepage use this code instead

    <?php
     
       if (is_home()) {
     
          query_posts('cat=1,2');
     
       }
     
    ?>
    Code (markup):
    where 1 and 2 are the category ids of the categories to be displayed..

    Now if you want to display all posts except posts from some particular categories use the following code instead

    <?php
    if (is_home()) {
     
          query_posts('cat=-1,-2');
     
       }
     
    ?>
    Code (markup):
    where 1 and 2 are the category ids of those categories which you don't want to appear on the home page...

    Hope this helps.. :)
     
    susan8051, Jun 5, 2008 IP