Support » Fixing WordPress » “Filter by Category” Main page, feeds, etc

  • Scenario: A blog used for both personal and technical posts intended for two audiences, “public” and “personal” either of which can view all posts, but they would need to open two urls and subscribe to two feeds. The main page of the blog should include all posts EXCEPT those categorized as “personal” and the feed links should include all posts except those categorized as “personal”. Basically, I would like two views for my site, all posts exluding personal, and just personal. The posts excluding personal should be available at and the personal posts should be available at something like“personal” or whatever. (<= I know this depends on my permalink settings, I can figure that part out by myself I think)

    Question: Is there any way to keep posts categorized as “personal” off my main page and out of my main feed?

    Disclaimer: I googled for “filter by category” but if this question has already been addressed please just share the correct terms and I will go read that information.

    Thanks: Thank you SO MUCH in advance for your help, I’ve been very impressed and excited about the features and ease of wordpress, this is my remaining issue keeping me from launching my blog.

Viewing 6 replies - 1 through 6 (of 6 total)
  • It would be possible to have for all posts except the private ones on the main ( or home ) page, and have certain URL for the private posts.
    Lets say I have the permalink structure:
    It doesn’t contain category, because I’m not that good an organizer, so I’m likely to change the name of the categories .

    In the loop I’d filter out the “private” category like this ( assuming “private” is category 4:

    <?php if (have_posts())
    : while (have_posts()) : the_post(); ?>
    <?php if ( !(in_category('4')) || !is_home() ) { ?>
    <!-- show the other categories -->

    ( If it’s not in category 4 OR if it’s on another page, show the post )

    The URL would be

    When you go to the “private” category page only posts in this category shows up.
    With the proposed permalink structure the special URL will be:

    Works for me.
    Good luck!

    Alternatively, in your root index.php add the following:

    if( !isset($cat) ) {
    $cat = '-4';

    above the line require('./wp-blog-header.php');

    Again assuming you want to exclude category 4. May have slighty different results to Petit’s solution, but works for me. Caveat – you can exlcude only one category with this method.

    wow Wow WOW! You two are the BEST! Thank you! I’ll post back when I’ve had a chance to try this. IanD, I’ve confirmed the file/location you reference (root ‘index.php’) but petit, I’m not sure where I would make your edits? It looks like maybe in the root ‘index.php’ of my theme? Again, thank you so much!

    Eh, sorry petit.

    “The Loop”

    Yup 😉
    In the loop, which is in any page that handles more than one post.
    All well?

    I just tried this. The code petit mentions works fine, just don’t forget to add a closing “}” before endwhile.

    The problem is that even if the entry isn’t displayed on the home page, it is counted for when displaying the number of posts you specify on the home page. So if your past 4 entries were in the category you didn’t want displayed and you only display 5 posts on your home page, you’d only be left with 1 entry on the home page.

    This page offers a solution that fixes that problem:

    I’m using that right now and it works perfectly with 2.0.1.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘“Filter by Category” Main page, feeds, etc’ is closed to new replies.