Well, I’ve gone and done it the hard way.
This goes in my-hacks:
function the_category_IDs() {
$IDs = array();
$categories=get_the_category();
foreach ($categories as $category)
{
$IDs[] = $category->category_id;
};
return $IDs;
}
function isthree($post) {
return (in_array(3,the_category_IDs()));
}
function remove_posts($function) {
global $posts, $post;
$newposts = array ();
if (stristr($function,'!'))
{
$function = explode('!',$function);
$function = $function[1];
foreach ($posts as $post) {
if ($function($post))
{
$newposts[] = $post;
}
}
} else {
foreach ($posts as $post) {
if (!$function($post))
{
$newposts[] = $post;
}
}
}
return $newposts;
}
the_category_IDs() is a function I had written before that returns an array of the categories of $post.
remove_posts() takes a function as a parameter. This function should accept $post as a parameter, and return a boolean. Any post for which the function returns True will be removed from the array of posts returned by remove_posts(). If remove_posts() is passed the name of a function preceded by ! it will remove all posts for which the function returns False.
isthree() is just a function that tests if a post is of category 3. You can replace it with whatever test you want to perform on your posts.
Then, in my index.php, I include this immediately before the Loop:
<?php $posts = remove_posts('isthree') ?>
Note that removing posts this way will reduce the total number of posts. IE: if your posts_per_page is set to 5, and 3 of your posts are removed, then you will only display 2 posts. I’ll see what I can do to improve that.