Skip to content

Hide certain categories from displaying on your homepage in Wordpress

Monday, October 27, 2008 - 23:43
>First of all you need to find this piece of code in your theme, either in home.php or index.php
<?php while (have_posts()) : the_post(); ?>
Then you need to insert this piece of code directly below it
<?php if (in_category('235') && is_home()) continue; ?>
But you need to replace 235 with your category you want to exclude. You can find the category by going to manage-categories, then you need the ID of the category. Now that's how you exclude a category from the homepage in Wordpress.
Yahoo Buzz Up! del.icio.us Digg Magnoliacom Reddit Technorati Twitter Facebook Furl Google LinkedIn Mister Wong MySpace Newsvine Propeller StumbleUpon

Author

evl

Comments

Hey, thanks! I was looking

March 31, 2009 by Rafal (not verified), 31 weeks 4 days ago
Comment id: 2437

Hey, thanks! I was looking for such a solution for some time now.

It seems that one needs to use "&&" instead of "$$" to make it work. I'm not into PHP at all though.

BTW. Wprecipes' post is about excluding categories from RSS feed, not the main page.

Thanks, I have fixes this

March 31, 2009 by evl (not verified), 31 weeks 4 days ago
Comment id: 2438

Thanks, I have fixes this now.

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <ul> <ol> <li> <dl> <dt> <dd> <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <cite> <param> <strike> <caption>
  • Lines and paragraphs break automatically.

More information about formatting options


CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
9 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.