WordPress.org

Ready to get started?Download WordPress

Forums

Can I only show post from a certain catagory in hompage? (6 posts)

  1. wwjoe
    Member
    Posted 8 years ago #

    Hey all, I'm wondering if you can restrict the posts that appear on your home page to one category? Thanks.

  2. brittanie
    Member
    Posted 8 years ago #

    Yes you can. Look here and follow the first link.

  3. wwjoe
    Member
    Posted 8 years ago #

    Well I tried it but didn't have any luck, my home page still showed all posts. I'm not sure where to place the code in the index.php page. Can anyone point me in the right direction as where to put it? Thanks!

  4. brittanie
    Member
    Posted 8 years ago #

    There is more info here but it says it only applies to WordPress v1.5. There also is, apparently, a plugin, but I haven't used it so your mileage may vary. Post back if these options don't work.

  5. Michael Bishop

    Posted 8 years ago #

    Note, there are several ways to accomplish this, I'm offering one that I use often.

    The loop generally starts with
    <?php if (have_posts()) : ?>

    So just before that add <?php $wp_query->set( 'cat', '2' ); ?>
    <?php query_posts( '' ); ?>

    Where the 2 is the category you want to show on the page.

    I'd suggest saving your index.php as home.php and adding the code there, just in case the theme you are using doesn't have all the templates. Otherwise, if you don't have the additional templates, the posts would be limited to the one category.

  6. wwjoe
    Member
    Posted 8 years ago #

    Miklb your method worked perfectly, thanks so much. Brittanie I'm going to look at the plugin next, I can see I'm going to need to get a better handle of the inner workings... Thanks all!

Topic Closed

This topic has been closed to new replies.

About this Topic