June 4, 2009

Excluding a category in WordPress

Over on my beer blog I have an entire section of "Press Releases" that I post but which I don't want to show up on the main page or in the RSS feed—I don't want to spam readers with excessive marketing but I like have the repository.

Since I'm now using WordPress, I figured I'd simply grab a plugin that would do the work for me: exclude the category from my "content" portions of the site (like the front page and the feed) but still let people access that category directly so they could see the Press Releases if they so chose.

To that end, I'd been using the "Category Visibility-iPeat Rev" plugin which seemed to do just the trick: I could configure exactly what category shows up in what area: front page, sidebar listings, search results, feeds, and archives. So I'd been using that up until now when I noticed a couple of bugs:

  • The individual category feeds weren't working; that is, when you went to a specific category and added "/feed" to the end of the URL, the RSS feed would load for that category but it would be empty. These normally work in WordPress, and it's a nice feature to have, and I wanted/needed it to work.
  • The plugin specifically excludes tags entirely (though unintentionally): any defined tags in the system were getting recorded into the database with all options off. I'm not using "tag browsing" anywhere on the site (yet), so this didn't affect me, but I might in the future and other people are complaining about it.

So I spent a little bit yesterday looking at the Category Visibility plugin code to see if I could fix the problem, and then looking at just adding the exclusion code myself to the theme so I could deactivate and remove the plugin entirely.

I couldn't find anything overtly wrong with the plugin code itself, and I didn't want to spend too much time digging around WordPress's core and driving myself insane, so I turned to adding exclusion code to my theme files.

You want to exclude the category ID from the query before the code even runs what WordPress ominously calls "The Loop", so a call to query_posts() is in order. To exclude a specific category, you'll do this:

query_posts('cat=-3');

The minus sign in front of the category ID (3 in this case) is the exclusion operator. If you omitted it, you'd be telling the query to only include category ID 3.

So I dropped this line inside some logic to check if it was on the home page or the archives page (is_home() and is_archive(), appropriately enough) and then ran into another problem: paging back through "Older entries" was broken.

Turns out just setting 'cat=-3' overrode the entire query WordPress was working with, so telling it to go to "/page/2" wasn't registering. I dug around online and instead this is what you should do:

query_posts($query_string . '&cat=-3');

That preserves any other query variables that were passed to the system, like what page you were on, and still appends your category exclusion logic. Worked like a charm.

All that was left for my goals was to exclude the Press Releases category from the site's main feed. After digging around online some more, I determined that a filter hook needed to be applied to the feed query, and found some example code which I adapted to this:

function exclude_pr_feed( $query )
{
  if ( $query->is_feed ) {
    $query->set('cat', '-3');
  }
  return $query;
}
add_filter('pre_get_posts', 'exclude_pr_feed');

That snippet was put into the theme's functions.php file and performs the same exclusion logic as above, only when posts are being pulled and the feed output is being built. So far it suppresses Press Releases from the main feed but hasn't affected the individual category feeds, including that for Press Releases. Which is perfect for my purposes.

The nice thing is that this is overall a relatively minimal impact to the system and I save the overhead of Yet Another Plugin. And hopefully this will prove useful to someone else who wants to accomplish the same thing.

Posted by jon at 11:47 PM : Comments (0)


June 1, 2009

Tilting at windmills

Two books are currently in my "active" pile right now (that is, that I'm actively reading):

Beer in America: The Early Years 1587-1840, by Gregg Smith. Interesting, though I just started. Too soon to tell if it's grabbing me as much as Ambitious Brew did.

Don Quixote. The "Wordsworth Classics" paperback edition, and truth be told I'm slogging rather slowly through it; I have a theory or two as to why.

First of all, it might be the translation; older or more "literary" translations seem to be drier, somehow, and lose the spirit of the original (e.g., rousing adventure story). I think a fresh(er) approach would work wonders.

Second, and this might be a symptom of translation, the format is incredibly dense and hard to follow—small type with run-on sentences and dialog that are all combined in single paragraphs that can span pages. Just breaking up the dialog into eye-friendly chunks would work wonders.

Finally, my current pet theory is that these classic literary authors were working without word processors, so editing and revising was such a pain in the ass that they just published first drafts. Which any editor will tell you are pretty unreadable.

Cervantes could have shaved off a good 50,000 words if he'd just had access to a computer. It would work wonders.

Posted by jon at 11:55 PM : Comments (0)


May 29, 2009

My annual TV diatribe

Seems like I do this every year, after the TV season has (mostly) ended. And year after year I seem to be watching the same damn shows. What's up with that?

Lost was better this year than it has been, but that's still not saying much as they've continued to veer into left field for no discernible reason. Time travel, Egyptian mythology, the sudden retcon of Jacob into everyone's lives... I swear they keep making this stuff up on the fly, don't let any talk of a "master plan" tell you different. At this point I feel like I'm slogging through the show more out of inertia than anything. And sometimes it is a slog.

24 started out strong but after the first four or six episodes it jumped the rails somehow. Actually, I have a theory about that: those first few episodes were first written and filmed last year, just before the writer's strike shut down Hollywood and canceled the season of 24. So they were off to a good start, got shut down for a year (or six months, or whatever), then came back in (possibly with new writers? Not sure) and tried to pick up where they left off—but they'd already lost it. It was just a chore to watch, not unlike Lost.

And what's with the way it ended? Way too many loose ends and plotlines left dangling. It felt like it didn't end, actually, which is a problem—not like a cliffhanger, which is a different beast, but like they had another couple of episodes to film and got cut short. Weird.

I was not at all an Adam Lambert fan on American Idol this year. I'm glad Kris Allen won. That's all I'll say about that, other than having my faith restored in the collective good taste of the voting American public.

The Office was probably my favorite show again this year. It's just brilliant and hilarious, outstanding really.

I loves me some Law & Orders, and though I'm a bit tepid on SVU, I'm loving this season's plain-vanilla L&O and since Criminal Intent is finally back on with their new episodes, it's one of the few shows I actually look forward to watching. (I know, the "new" CI episodes already aired on the USA channel before the NBC "season" started this month. I don't watch USA, okay?)

Scrubs was "back" on ABC this time around and it was good... but not as good as before. Just wasn't feeling it as much. Though I thought they handled the series finale really well.

I started watching The Unusuals and was rather enjoying it, so naturally ABC decided to cancel it. (They were probably sick of my bitching about Lost.) Quirky characters, fast-paced, no overall "mystery storyline" that would require three years to unravel... just a decent cop show.

Speaking of decent cop shows (or not), one thing I simply do not understand is how CSI: Miami can continue to be on TV. It's the most ridiculous show I've ever seen. The only redeeming quality is the opening one-liner. And it seems like even that is starting to consume itself lately.

Of course, when all else fails there's always Cartoon Network.

Posted by jon at 11:35 PM : Comments (0)


May 7, 2009

They're always after me pot o gold...

The other day in Bend we had a terrific full rainbow fully visible right out our back door. The camera doesn't have a wide enough angled view to get the whole thing, so I took three pictures and stitched them together:

May rainbow in Bend

Click on it for a larger version.

Posted by jon at 8:14 AM : Comments (2)


April 22, 2009

Anniversary of my blog. Oh yeah, that other day too.

Today marks seven years since I started this blog. Seven! Strangely enough, I launched on Earth Day without even knowing it. So when I talk about the significance of "April 22nd" I'm usually not on the same page as everyone else.

Posted by jon at 11:29 PM : Comments (0)


April 17, 2009

Random bits on a Friday night

→ My porting of The Brew Site to WordPress worked out remarkably well (minus more fine tuning I still need to do), so sooner or later I'll get around to porting this site over as well.

→ Not sure what to do with the ebooks page anymore. It's not going anywhere (I don't like linkrot), but the Palm eReader platform they were all released for seems to no longer be a relevant format. Seems like Mobipocket is the way to go: it's supported by all main platforms, it's an open standard (with development tools, I think), and even Amazon.com has adopted it.

Of course, I have less time than ever to even think about offering up new ebooks...

→ We went to the school's Family Fun Night this evening and actually won the drawing for a weekend coast getaway—a condo in or near Newport.

→ Last weekend I opened up some mystery bottles of homebrew that had been in storage for an indeterminate (but fairly long) amount of time.They were actually not at all bad; one was very oxidized and reminiscent of a sherry—no idea what style it was originally—the other was a stout, also oxidized but not as badly. Kind of fun tasting mystery brews like that, so this evening I put four more bottles in the fridge to taste this weekend.

In this case, I know for sure what at least one of them is: the second beer I ever brewed, a honey wheat ale. Vintage, mid-nineties.

For reference, I have several bottles of my early batches of beer: one bottle of the very first batch I brewed, a generic amber-ish ale; a bottle or two of the honey wheat; one bottle of the third(?) I brewed, a porter; a bottle of an Oktoberfest (very early also, but I don't recall exactly when); and one or two bottles of "Capricorn Porter", a beer brewed with all sorts of things like juniper berries and licorice and such. It dates to '96 or '97 I think.

There are also several other unlabeled bottles as well. I can't speak for certain how any of these have held up with questionable storage conditions, but who cares? I'm having fun with the adventure. Anyone want to get in on it?

Posted by jon at 11:46 PM : Comments (2)


April 12, 2009

Happy Easter

Kind of a gray, cool day so far, contrary to what the weatherman was predicting. Hope everyone's having a nice Easter morning, and remember, the Easter Bunny goes back to his old self tomorrow...

Posted by jon at 11:26 AM : Comments (0)


March 31, 2009

Anathem

I mentioned awhile back that I received Neal Stephenson's Anathem for my birthday. This is his latest novel, a monstrous tome that weighs in at nearly 1000 pages, and was released in the latter half of last year. Early reviews seemed really lukewarm to me, in part because of the reveal that Stephenson employs a large invented vocabulary—which often seems to be a crutch or gimmick in the hands of inexperienced writers (not that Stephenson is one)—and in part because it seemed like following up The Baroque Cycle would be really, really hard.

Well, forget all that. Anathem is a fantastic book, and Stephenson's best to date. Not only has he matured as a writer (leaps and bounds past his earlier works), he's put together a tightly-plotted, internally consistent story that's just dripping with good ideas and has at least one jaw-dropping, mind-blowing concept that, well, becomes a key plot point.

And, this book actually comes to a solid, satisfying conclusion—one of the major criticisms I've had with his earlier works.

It's simply a joy to read, and I actually wanted to re-read it almost as soon as I'd finished. That's a difficult trick to pull off.

Posted by jon at 11:20 PM : Comments (0)


March 22, 2009

March 2009's first post

And just like that, winter is officially over and spring has arrived. No one's told the weather, yet, but it'll figure it out sooner or later.

I think this past month has been my worst non-blogging streak at this blog to date. Sorry about that. I've actually jotted down notes here and there of things to write about but have just been—frankly—too lazy to make the effort to get them down.

I've been porting over my Brew Site blog to run on WordPress, as promised, and it's been mostly painless. The biggest effort was mapping the database fields and writing the SQL to convert the data from the old tables to the WordPress tables... which turns out to be not that big a deal. Actually, that wasn't the biggest effort; the biggest effort was creating the theme to more-or-less match what I had before. It's mostly done, good enough for government work anyway, though I'll still be twiddling around with it for a while and I already have ideas for something new.

Next I'll convert Hack Bend over and finally this blog. Those conversions should go quicker now that I have a pretty good idea of what needs to be done. I'm pretty sure I'm going to open Hack Bend up to multiple contributors. Who wants to write for it? It's all free, of course, at least until I can figure out how to enable different Google AdSense users.

That's all for tonight. Next post: a review of Neal Stephenson's Anathem.

Posted by jon at 11:11 PM : Comments (1)


February 15, 2009

And I don't even have Monday off

Depending on how you look at it, my weekend was either eventful or not. It started with me (finally) catching my wife's cold—this started Friday actually, as I woke up feeling cruddy and was generally run down by the end of the day.

"It'll get worse," my wife said. So I was instructed to stay laid-up as much as I could during the weekend, which isn't really practical when it's Valentine's Day and the coffeepot dies.

And there must be coffee. Right? Right? So I popped over to the nearest coffee stand and grabbed a couple of cups, and later in the morning we made the pilgrimage to Costco for a new coffeepot.

Our usual Valentine's tradition is to pick up Papa Murphy's heart-shaped pizza for dinner and split a bottle of champagne, as a family. No, the kids don't get any champagne, stop thinking like that. Oh, and chocolate-covered strawberries. This year, my wife and the kids made the strawberries while I napped and sniffled.

It was a nice evening, even with a cold. It's one of those colds with sinus pressure, which is no fun, and I seem to have a stiff neck too for some reason. Not sure if I slept on it wrong or what. Beyond that it's not so much debilitating as annoying.

Today was a very lazy day, just keeping restful and low-key to speed this cold along. I read a bit, laid down a bit, folded my laundry, that sort of thing. Now it's 10:30 or so and I'm getting ready to go to bed pretty soon. (Normally it's around midnight before I go to bed.)

Working tomorrow. Should be mostly fine, but in case any of my co-workers are reading this, rest assured that I should be past the contagious point and I probably sound worse than I actually feel.

Posted by jon at 10:39 PM : Comments (2)


February 13, 2009

Numbers

In case you missed it, today is Friday the 13th. Which, you know, is supposed to be unlucky.

But you know what? We know all that. There's actually a more interesting numerical occurrence today: Unix time will reach 1234567890. That is, it will have been 1,234,567,890 seconds since January 1, 1970—when the Unix "Epoch" starts counting from. Only computers running Unix-based operating systems apply.

It's just a fun geeky coincidence, but you just know some conspiracy nut out there will freak out over this numerical conjunction.

That might make for an interesting story...

Posted by jon at 11:43 AM : Comments (3)


February 10, 2009

Idea: print on demand, blogs, and magazines

Here's an idea (or several) that has been banging around in my head for a little while now: print on demand (POD) magazines generated from blogs.

It's not a new idea—ironically, shortly after I began thinking about this, I discovered OpenZine, a site/service which seems to do the same type of thing—but right now it would be stupidly easy to implement it. All you really need is some software on your website (in PHP, ASP.NET, whatever) to insert blog posts into a nicely formatted PDF, and hey presto, instant magazine that a user could read online or print out.

But extending the idea a bit more: what if instead of the "owner" (or blogger or whomever) doesn't select what to publish to the "magazine" (since it's virtual), but the end user gets to pick what articles should appear? Either by selecting specific articles (blog posts, reviews, whatever), or by setting some search or filter parameters (the last 10 new articles in the "beer review" category).

Then not only do you have a print on demand magazine built out of your blog—at no other work from you than writing your blog (like you're doing anyway)—but it's customizable on a user-by-user basis.

Sure, they could just go to your blog (or a specific post) and click "print"—but this would be just as easy and they'd get a (custom) layout that looks like a magazine and could be (should be) much more readable than a straight printout.

Again, there's no magic here; it would still be stupidly easy to accomplish.

What about monetizing your POD blog magazine? Some bloggers are going to want compensation, after all. Since the user is already choosing what content they'd like to have in their magazine, why not let the user also select what advertising they'd tolerate in it? This would be more complicated, of course, because then you'd actually have to be selling adspace and have a variety of ad topics to give the user lots of choices. And they couldn't be clicky ads, either—it's intended for print, remember, so clicky ads don't make sense.

But I'm sure that if there's not already a third party service out there to broker ads for you in this type of manner, someone could set one up pretty easily. Maybe?

I don't know quite how the payout would work for this... perhaps when the user builds their POD 'zine and selects their ads, it would mark that ad as "sold" and you'd get a payout of whatever set fee. No commitment, no risk, and no cost to the end user (other than the paper they print it out on).

All the pieces are out there, there's nothing from a technical standpoint that would prevent this. The questions then are:

  • Has anyone put all the pieces together and is doing this?
  • If not, why not?
  • Would (enough) people be interested in a POD zine?
  • Would people actually do the "print" part of POD? Or just read a PDF? (If they don't print it out, then it's pretty much pointless)
  • Would advertisers be interested in this?
  • Is there such an ad broker that I speculated about?
  • Would you use it?

Seriously, this could be a WordPress plugin by next week.

Posted by jon at 11:28 PM : Comments (2)


January 30, 2009

What actor(s) would you like to see on 24?

My wife found this article today on the possible end of the TV series "24" after the next season (season 8). Nothing really earth-shaking here, but it sort of ties in with a thought I've had for a while and hadn't gotten around to blogging, until now.

The thought is, what actor(s) would you want to see play the lead role on "24"? Either as a replacement for Kiefer Sutherland, or perhaps if there were a spinoff or whatever. What actor or actors could fill a Jack Bauer-esque role?

I have a few ideas, mostly dredged from the rosters of other TV shows because bringing in a movie star would, I think, mostly overwhelm the rest of the show. (Of course, that's what they did with Kiefer, and look how that's turned out...)

Of course, there's nothing stopping you from nominating a female actor for the show, either. After much thought my own picks would be Michelle Forbes (who ironically had a guest starring role on "24" during the second season) and Angela Bassett (based on what I've tangentially seen of her on "ER").

But then again, "24" is a big show, so bringing in a big (movie) star might be the way to go after all. I'm not sure I could pick one, though... I keep thinking Keanu Reeves (basically the role he played in "Speed") would be a good pick...

Posted by jon at 11:44 PM : Comments (1)


January 23, 2009

2008 in review, part 6

Finally caught up with my 2008 year in review! You can read Part 1, Part 2, Part 3, Part 4, and Part 5 if you haven't already.

November

November was really a pretty uneventful month. The kids were in school, I was entering my third month of my new job and we were all getting back into the swing of things.

I hit up the annual Deschutes Brewery Garage Sale and walked away with a couple of T-shirts, and a case of the 2008 Abyss.

We had a nice Thanksgiving at our house, and even though I had cooking chores it was the easiest Thanksgiving meal I've prepared in recent memory. It was a fully traditional dinner, with turkey, stuffing, mashed potatoes, candied yams, and so on; everything just clicked I guess, and I wasn't running around like a chicken with my head cut off trying to get everything done.

Which is a nice was to start a long holiday weekend.

December

The month started out right, by getting a new computer to replace our old, slowly dying one. It was a really good Black Friday deal from Dell, and so far I'm liking it just fine.

The first Saturday we went downtown to watch the Bend Christmas Parade, and like Halloween, this was the warmest Christmas Parade day we've had in a long time; I believe it reached 60 degrees or something wild like that.

Our company Christmas party was the best such party I've experienced in years—have I said already that Smart Solutions is a good company to work for?—and I walked away with a new Blu-Ray player as a raffle prize. No, I'm not kidding.

My birthday popped up again this year (funny how that keeps happening) and I celebrated 36 revolutions around the sun.

Christmas was great, as always. The best part of having kids is re-capturing the Christmas excitement we all used to feel when we were kids. Santa was good to us this year, bringing sleds for the kids even, and since it was a white Christmas (rare in Central Oregon!), we were able to get a bit of sledding in at my parents' house—first time in years.

And finally, New Year's Eve. I've written recently about how we planned to have a (smallish) New Year's party, but unfortunately the kids got sick and we changed plans, and had a much quieter evening with a couple of friends. We celebrated 2008 and rang in 2009 with beer and champagne and good company, and here we are.

Posted by jon at 10:41 PM : Comments (0)


January 18, 2009

2008 in review, part 5

Previous installments: Part 1, Part 2, Part 3, Part 4.

September

The beginning of the month was the latter half of Labor Day weekend, with my brother and sister-in-law still in town for another day or so. More beer drinking ensued.

On the third, I officially started my new job with Smart Solutions; I had been interviewing/talking with them for a few weeks before finally accepting, and as my first day coincided with the second day of school (and my last job ended right about when school let out in June), it was a lot like I'd "merely" taken the summer off.

Much of the rest of the month was uneventful as we discovered and fell into the new patterns of kids being back to school and my new job, but we definitely started to breathe easier and loosen up on the budget restrictions somewhat.

We made it downtown to Deschutes Brewery's Jubelale launch party in the later half of the month for dinner and tasting of this year's seasonal. I walked out with a free poster of the 2008 Jubelale label, signed by the artist.

And, we (finally) visited Three Creeks Brewing in Sisters at the end of the month for lunch and to check out the beer (and so I could write about it). It has good food and decent beers, and is definitely a win for Sisters (but not someplace we can get to very often).

October

One of my big goals at the beginning of 2008 was to attend the Great American Beer Festival in October. Seriously. Since it was going to be The Year for me as a Beer Blogger, I was all set. Unfortunately, my hours were cut, I lost my job, and then finally got a new job a month before, all of which kind of derailed those plans.

Early October revealed one of the perks of accepting a job with Smart Solutions: they sent me on a three-day business trip to Simi Valley, California (along with three co-workers) to attend SEO training. Maybe this seems ho-hum to many, but for me this was my first such business trip and, well, it was a big deal.

Mid-month, we went to Deschutes Brewery's Fresh Hop Beer Tasting at their Mountain Room. Besides the Chocolate Beer Pairing Dinner (which was free to me), this was the first Deschutes event I've attended; it was a much more informal event than the Chocolate Pairing dinner, and the beer was flowing like water. Very cool, and worth doing again.

The final weekend of October we decided to take a trip out of town, and ended up visiting Hood River to pick apples. No kidding! We wanted a get-away weekend without any real schedule, and so checked out the Hood River Fruit Loop without any expectations. We left Saturday morning, made it to Hood River by lunchtime and found a great little orchard/BBQ place to eat. The rest of the afternoon was spent visiting various other orchards around the area, picking or buying apples (and pears), and generally having a good time. We ultimately ended up with about 25 pounds or so of fruit.

We capped the day with some drinks at Full Sail Brewing in downtown Hood River before driving into Portland to spend the night; it was a brief visit though, so I didn't write about it. (Next time.) In Portland the next morning we visited our friends Justin and Raegan and their baby (whom we'd seen back in June also), and went out to breakfast with them.

Ironically, Justin was also coming down to Bend the next day on a work-related trip, so we went out to dinner that Monday night and got to visit even more.

Then, of course, Halloween capped the month; it was the warmest Halloween in recent memory, where we didn't have to bundle up before going out trick-or-treating. The kids hauled away more candy than ever, probably because we were able to last longer without suffering frostbite.

Posted by jon at 10:49 PM : Comments (0)


Earlier entries