Posts Tagged ‘hacking’

WordPress: Auto Tag while you sleep! WPCalais meets the cron job

Wednesday, July 23rd, 2008

So working on allbiodiesel.net I came across a great plugin by Dan Grossman, WP Calais Archive Tagger, which is really only the step brother of the WP Calais Auto Tagger, which due to its granular application is less interesting to me.  Basically this plugin parses your blog posts, analyzes your text, and spits bag tags that it thinks are descriptive of the blogpost.

Hm, no big deal you might say, and I would agree if you’re talking about a little blog (like this one for example), where you don’t write that many posts.  However, once you start thinking about feed aggregation, this becomes a fascinating -  and extremely useful - tool.  With hundreds of posts coming in every day (I use FeedWordPress), there’s no way I’m going to tag all of them.  Being able to automatically parse and tag posts become invaluable then.

The problem: WP Calais Auto Tagger lets you auto generate tag as you’re writing the post.  However, with feed aggregation, you’re not actually writing the post, they are generated automatically.  So this is useless. Ok, WP Calais Archive Tagger is getting close to the problem: it lets me autotag my entire archive of posts.  Ok, so I tag 300 posts, and the next day 50 are added… well, it tags all 350 now.  Plus I’d have to go in and manually hit the button.  Do I want to do this every day? No.  So, what I am was looking for was something that would do this automatically for me.

I’ll be the first to admit, my PHP programming skills are horrible, totally not 733+.  However, I can look at some code and figure out what’s going on.  A few echo statements sprinkled throughout and I catch on; change a variable here or there and see what it does, ok, I get it.  So I took the WP Calais Archive Tagger code, stripped it down so that it could be run through a cron job (meaning it had to instantiate the WP environment itself), and voila, I’ve got posts coming in automatically and then soon thereafter being tagged… automatically. While I’m sleeping.  My tag cloud is building itself.  Knowledge, patterns, trends emerging while I sit back and relix.

Pretty cool.

Anyway, long story short, here’s the file I hacked up.  Enjoy!

http://www.leeclemmer.com/calais-cron-tagger.rar

Update (8/20/2008): Please be aware that you need to have the Calais Archive Tagger installed first for this to work ;)