tips and tricks for movable type
category count excluding one category
June 15, 2003
Kristine whipped up some PHP using the FilterCategories plugin to give you a total count of all entries in your blog less those in one particular category.
<?php
$all="<$MTBlogEntryCount$>";
$not="<MTCategories><MTFilterCategories include="general">
<$MTCategoryCount$>
</MTFilterCategories></MTCategories>";
echo $all-$not;
?>
$all="<$MTBlogEntryCount$>";
$not="<MTCategories><MTFilterCategories include="general">
<$MTCategoryCount$>
</MTFilterCategories></MTCategories>";
echo $all-$not;
?>
Replace general with the name of the category you want to exclude.
Found in this MT support forum thread.
TrackBack: 1
(URL: http://www.thegirliematters.com/sf/mt-track.cgi/154)
» entry count
Excerpt: hee hee, I love it when my php codes make people happy :) [the girlie matters] entry count excluding one...
Weblog: kadyellebee
Tracked: 06.15.03 09:30 PM
Comments
Can I use this to exclude more than one category? Example:
include="cat1,cat2,cat3"
Yes, the FilterCategories plugin permits you to list several categories; but use this syntax instead:
include="cat1|cat2|cat3"
So as far as I know, it should work that way as well!
"Replace general with the name of the category you want to exclude."
is that correct?
Oh man... that's so freakin' obvious and I never thought of it and I should've used it in a code that I wrote and have been not 100% satisfied with... dang, K rocks too... and Girlie is hot ;) (for someone who isn't my wife)
Okay now, will this work if your site is category-free? ie you only have one category set up but that's the one you want to exclude?
Iced Glare - yes, the statement is correct (exclude).
Robyn - I see no reason why the code wouldn't work in that situation.
Thanks Girlie.
Sadly it's not working for me; all categories are showing up and the extra PHP keeps messing with my page layout (I had the margins set at a specific width). Argh!
"All categories"? I thought you had only the one category??
Did you install the FilterCategories plugin?
The php shouldn't mess with your page layout; it just generates a number. Do you have a URL to look at where you're using the code?
I did have just the one category, but it's not being excluded (if that makes any sense). As far as I know the FilterCategories plugin has been installed, but MT is installed on a communal server moderated by another person who may not have actually installed it yet...
Anyway, I've decided to code this section of the site by hand anyway, as I'm getting out of practice! Thanks anyway.....!
hi,
i'm trying to use MTSQLEntries to filter all but one category, but it seems like in mt_entry, the table, all my entry_category_id values are NULL.
so, i wonder where in the world is mt pulling category information?
any help'd be much appreciated.
thanks!
Look in mt_placement. =)
i AM AS LUCKY man to find your weblog. its very nice. i have a question: could you please write me how can i use Email this entry plugin in my weblog.
please give me details.
thank you