Support » Fixing WordPress » Can I only show post from a certain catagory in hompage?

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Yes you can. Look here and follow the first link.

    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!

    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.

    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.

    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can I only show post from a certain catagory in hompage?’ is closed to new replies.