WordPress.org

Forums

One Category On Front Page? Possible? (7 posts)

  1. stealth
    Member
    Posted 8 years ago #

    Hi All

    Is it possible to just display one category of posts on the front page instead of all of them?

    Cheers

    Stealth

  2. sanchit
    Member
    Posted 8 years ago #

    http://wordpress.org/support/topic/87020?replies=4#post-444035
    http://wordpress.org/support/topic/38210

    <?php
    if (is_home()){
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=12&paged=$page");
    }
    ?>

    This will only display posts from category 12. Change the number in query posts to your category. And put this code in your index.php or whatever file.

    Soo many people are going through the same issues I had a week ago.. :\

  3. stealth
    Member
    Posted 8 years ago #

    Where do I put that???

  4. Chris_K
    Member
    Posted 8 years ago #

    As he said, you'd put it in your theme's index.php. Might be worth reading up on The_Loop.

    Or, you could look into one of these two plugins:
    Category Visibility plugin.
    Ultimate Category Excluder plugin.

  5. mujahideenryder
    Member
    Posted 8 years ago #

    I added the code, but the post apears twice, instead of once.

  6. mujahideenryder
    Member
    Posted 8 years ago #

    Nevermind I got it working.

  7. bornfamous
    Member
    Posted 7 years ago #

    Is there a way to put more than one category in that code? Sorry for the dumb question. The plugins mentioned don't work with 2.3.x.

    [Update: I found my answer in the comments on this page.]

Topic Closed

This topic has been closed to new replies.

About this Topic