Exclude Posts Belonging to a Category

June 6th, 2009

UPDATE 06/08/09
This didn’t work out the way I planned, so I had to do something else


OK – so I have this nifty plugin that lets me post new blog entries to my twitter profile (Twitter Tools). The plugin also posts a weekly digest of my tweets. The problem is that I don’t want the weekly digest posted to my homepage; however, I do want the weekly digest posted to the blog, so I needed to find a way to filter a category from my homepage.

I searched wordpress.org support and found several plugins that sort of did what I wanted, but it seems ridiculous to install a plugin for something as simple as filtering a query, so I continued to search and found a helpful list of Query Posts that would handle the filtering. I then had to place the code before the WordPress Loop, so the category would be filtered out before the loop started. Here’s what I ended up using:

<?php
if (is_home()) {
query_posts("cat=-3");
}
?>

where 3 is the ID of the category you want to exclude from the page – and don’t forget the minus sign (-) before the ID number.

I opened the index.php file in a text editor, but you can use the built-in WordPress theme editor or file editor if you wish. I then had to place the code before the loop began:

<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php
if (is_home()) {
query_posts("cat=-3");
}
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post">

You’ll need to know the ID of the category you wish to exclude in order to do this. To find the category ID from the Dashboard, go to Posts → Categories and hover over the category name. When you do this the link address will appear in the bottom left of your browser (or wherever the onHover link address appears in your browser). At the end of the address you’ll see …cat_ID=3 – whatever the number, that’s the ID for that category.

It didn’t take me long to find all this information, but I had to look in several places for the entire process, so I hope this saves someone some time.

Things to understand:
With this method you can only exclude posts that belong to one category. If a post belongs to two categories, it will still be posted.
This method addresses posts to the homepage. The posts will still appear on the category’s page, and the category listing will still appear in the sidebar.

The Governator. Can you digg it?

May 31st, 2009

A few days old (translation: old news), but this is a great interview with California Governor Arnold Schwarzenegger. I don’t agree with everything the governor believes in, but he never ceases to impress me. And I will never understand why he’s considered a Republican.

I’m not a huge fan of cnn these days, but this ireport/digg dialog thing is kind of cool.

take care always

I don’t know German, but Rhabarberbarbara

May 31st, 2009

I have no idea what in hell this is or what it’s saying, but I found it oddly amusing. I’m sure if I understood what was going on, I’d find it brilliant, but I’m not smart enough for any of that. Still – I hope you enjoy and I’d like to thank brennarella for pointing me to it.

enjoy and take care always

From the Dog Track

May 23rd, 2009

Some images from my first visit to the dog races.

Update from the field

May 23rd, 2009

It’s stopped raining for now, but I’m sure that means it will be way too humid to breathe. I guess that’s the way holiday weekends go sometimes. Oh yeah – and I might have to work tomorrow.