On this post I will show you how to hide a particular post on your blog’s front page without the need to install a plugin. I have nothing against WordPress plugins it’s just that I’m the type of WordPress blogger who is as much as possible doesn’t want to install a plugin especially if there’s a code that I can use and do it manually by editing my theme’s template. On today’s post I will show you on how to exclude categories to be posted on your frontpage of your WordPress blog. This WordPress tweak has been tested in WordPress 2.3. This definitely works especially if your frontpage has page navigation.

* This varies depending on your theme, this is commonly used in a normal wordpress blog layout.

  1. Go to admin dashoard > manage > categories. Look for the category you want to exclude and identify the category ID. e.g. we want to hide category ID: 8.
  2. Still in the admin dashboard > go to Presentation > Theme Editor > open *index.php
  3. Inside the *index.php file, look for the line that says “<?php if (have_posts()) : ?> ”
    then paste this code after that line:
    ! don’t forget to change the id to your chosen category id

    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=-8&paged=$page"); ?>

    and before this code. “ <?php while (have_posts()) : the_post(); ?>

  4. Then Update your *index.php file.