Show all posts except those from one category (MT specific)

All “styling” has been removed (just so you can get the main idea…)
But here is the code to show all posts except those from one category…

<MTEntries>
<?
$cat = “<$MTEntryCategory$>";
$hidecateogry = "CATEGORY NAME YOU WANT TO HIDE";
if (!strcasecmp($cat, $hidecateogry )) {
//do nothing - hide this category’s posts
} else {
?>
<$MTEntryTitle$>
<$MTEntryBody$>
<?
}
?>
</MTEntries>

If you want to show just posts from the last 10 days… that <MTEntries> will be this instead: <MTEntries days=”10″>

12 Responses to “Show all posts except those from one category (MT specific)”

  1. Jennifer Says:

    If you’re using multiple categories - you might want to try this option shown on MovableBlog

  2. Mariann Says:

    Is there a way to modify this script to exclude more than one category?

    I’ll set the context. I’m preparing an online course, set within several frames, but the site itself also serves to distribute related links to students and scholars. Short of creating another blog to handle either the course or the resource page, I’m not sure how to get the student-specific entries (all organized in four 101 categories: 101 announcements, 101 documents, etc.) *out* of the resource blog.

    I’m rambling, I know… anyway, I just wanted to see if the script had been used to exclude more than one entry or if anyone had thought about such a feature. Your site has provided me with a wealth of information that I’m slowly digesting and incorporating on various blogs I maintain, and I very much appreciate all of your efforts! :)

  3. Jennifer Says:

    This should work (although I haven’t tested it):

    <MTEntries>
    <?
    $cat = “<$MTEntryCategory$>”;
    $hidecateogry = “CATEGORY NAME YOU WANT TO HIDE”;
    $hidethiscategorytoo = “OTHER CATEGORY NAME YOU WANT TO HIDE”;

    if (!strcasecmp($cat, $hidecateogry)
    || !strcasecmp($cat, $hidethiscategorytoo) ) {
    //do nothing - hide this category’s posts
    } else {
    ?>

    <$MTEntryTitle$>
    <$MTEntryBody$>

    <?
    }
    ?>

    </MTEntries>

  4. Mariann Says:

    Eh, I tried adding a line for each category within the same script — caught a typo in the script (hidecateogry - should be category) and my effort failed. Ah, well.

  5. Jennifer Says:

    It should have worked (even with the typo - as long as both references to that name were the same.) Did you fix the typo only in one location?

    Have no idea why it failed without more information.

  6. Mariann Says:

    Darn… still no luck. But thanks so much for responding so quickly with an option. I’ll keep playing with the script to see if I can get it to cooperate. :)

  7. Dave Says:

    Is there a way to modify this so you can hide category lists and not just the posts? Or does this only work with posts?

  8. Jennifer Says:

    Dave - not sure I understand your question.

  9. kristine Says:

    Dave - if you just mean that you don’t need to see the body of the post, just a list of links to posts, yes, this should work that way, too. For example: if you have a list of links to more recent posts on your sidebar but don’t want to show one of the categories in the list…
    If that’s what you mean, you’d just want to use different tags in the center of the MTEntries container (replacing the original <$MTEntryTitle$><$MTEntryBody$>:

    <a href=”<$MTEntryLink$>#<$MTEntryID pad=”1″$>”><$MTEntryTitle$></a>

  10. pulpo Says:

    okay!

    invisible categories are a great addition to MT and I’ve NEARLY hidden my category using the above method (just search to exclude next)

    FOR WHY AM I DOING THIS? Well, I need a hidden cat for beta testers to post to with their comments, insults or otherwise…

    but what about this?

    <!->

    <div class=”sidetitle”>
    Jump to
    </div>
    <div class=”side”>
    <Form>
    <select onChange=”document.location=options[selectedIndex].value;” style=”font-family:’Verdana’;color:003366;background-color:#FFFFFF;text-decoration:none;font-size:8pt; width=140″>
    <option value=”">Category…</option>
    <MTArchiveList archive_type=”Category”>
    <option value=”<$MTArchiveLink$>”><$MTArchiveTitle$>
    [<$MTCategoryCount$>]</option>
    </MTArchiveList>
    </select>
    </FORM>

    <Form>
    <select onChange=”document.location=options[selectedIndex].value;” style=”font-family:’Verdana’;color:003366;background-color:#FFFFFF;text-decoration:none;font-size:8pt; width=140″>
    <option value=”">Month…</option>
    <MTArchiveList archive_type=”Monthly”>
    <option value=”<$MTArchiveLink$>”><$MTArchiveTitle$></option>
    </MTArchiveList>
    </select>
    </Form>

    </TABLE>

    </div>

    <!->

    There is as you can see no category name to exclude in the (second) date archive pulldown (yeah.. I have to have pulldowns)

    + I get build errors wherever/wherever I try to wrap the (first) category listing menu in the required MTEntries tags with your snippet…

    (which incidentally has to be all over the place on my index to hide for example, recent comments in my hidden cat and so on but seems to works just fine. I must find a cleaner way to include it.)

    Is it possible to hide my category completely?

    tx!

    Pulpo

  11. Nate Says:

    Hello, I’ve been searching for a way to hide a category. What I want to do is this: I have a full page calendar and I’d like to have a category called “dates” or something that I can enter data for the calendar only. I’d like to hide all entries into the that category on my main page and on my category list in my sidebar. I’ve tried this suggestion here, but it seems to not be able to see my </MTEntries> at the end. It’s there, I’ve checked several times. I even tried moving the code around within my <MTEntries> and </MTEntries> tags. Any help at all would be greatly appreciated.

  12. Nate Says:

    Update:
    I got the code to properly rebuild, however when i post to that category and load the site, it breaks the CSS and shifts all the content that should be in the middle and has it all left aligned. Any idea why it would do that?