scriptygoddess

23 May, 2002

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

Posted by: Jennifer In: Scripts

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

May 25th, 2002 at 5:37 am

Avatar

If you're using multiple categories – you might want to try this option shown on MovableBlog

2 | Mariann

June 18th, 2002 at 1:19 pm

Avatar

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

June 18th, 2002 at 1:32 pm

Avatar

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

June 18th, 2002 at 1:44 pm

Avatar

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

June 18th, 2002 at 1:50 pm

Avatar

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

June 18th, 2002 at 1:54 pm

Avatar

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

June 18th, 2002 at 5:18 pm

Avatar

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

June 18th, 2002 at 7:51 pm

Avatar

Dave – not sure I understand your question.

9 | kristine

June 19th, 2002 at 11:21 am

Avatar

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

January 10th, 2003 at 8:37 am

Avatar

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

July 29th, 2003 at 11:39 pm

Avatar

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

July 30th, 2003 at 5:33 am

Avatar

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?

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements