[wp-hackers] Multiple category exclusion query

Brian Dupuis wordpress at coldforged.org
Mon Mar 7 22:29:15 GMT 2005


I've used a hacked classes.php forever to get my multiple category 
exclusions that I need for my site. It's a naive method where you either 
get inclusions or exclusions, nothing more, but it works for my 
application. I was getting tired of keeping the hacked version and 
figured I had some energy to invest in getting a "real" version [where 
"real" means that you can specify $cat strings of, for instance, 
"1,2,3,-29,-30" so that you'll get, in pseudocode, ((1 OR 2 OR 3) AND 
NOT (29 or 30)) so that you'll exclude items that belong to 1 and 29] 
going for possible inclusion in WordPress, so in my spare time I've been 
trying to get it up. As such, I've wracked my brain trying to come up 
with a query that does the necessary job and have failed. Utterly. The 
only things I can come up with are either subqueries (which aren't 
supported in MySQL 4.0) and temporary tables (which I'm afraid would 
negatively impact performance).

Has anyone else tried to crack this nut? Is it even _worth_ trying to 
crack? I see a couple of questions pop up every now and then about 
people trying to exclude categories and sometimes multiple, but not 
often. Mostly people recommend doing inclusion of every category but the 
ones you want excluded which works in some ways but doesn't in others 
and is a pain to deal with for any quantity of categories (my exclusions 
are 27 and 28).


More information about the wp-hackers mailing list