I went to the theme directory tonight with the sole purpose and intention of voting on the one theme I’ve been more than happy installing (K2, duh) and it wasn’t there! I assume this is because they’re working hard on 1.0, trying to get that out before they add K2 to the throng of themes already up for grabs. (They’re on RC7 now, I think.) Anway, I hope it’s that, and not that there’s some feuding or some other BS reason K2 isn’t listed.
Anyway, then I ended up following some links, and poking around in the K2 google code pages, and remembered that I’d started a thread asking for a particular feature for K2 back in February. I hadn’t visited the issue page in all that time, but there had been some responses, including a developer who said if I made a patch for the feature I was requesting, he’d see that it went in.
So tonight I made a patch. This officially marks the first time I’ve actually contributed (code) to an open source project. I suppose I’ve helped plenty of people on support forums and things before, but if this code makes it in, I’ll be… a geek hero or something.
For ReadComics.org I wanted to show the latest Book Club entry in the sidebar. For those of you who are not familiar with the way Wordpress does its posts, it uses some funky wrapper functions to access (and sometimes print) the entries in your blog. The main wrapper function, and the one that controls most of the stuff on the page is called the_loop().
This might be getting too detailed… You probably just want to know how to do what I did. There’s a lot more details on wordpress.org about using multiple loops on one page, but basically, the technique I used was to specify a new loop by using one of its internal functions called WP_Query directly.
WP_Query() takes an argument that tells it to just get the latest post from the book-club category. That looked like this: <?php $bc_query = new WP_Query('category_name=book-club&showposts=1'); ?> This uses category slug (”book-club” in my case), which you can find by editing your category.
So then you can use the standard functions like the_title() and the_excerpt() in a while loop. So the whole thing looks like this:
<li><h2>Next Comic Book Book Club</h2>
<!-- Get the last post in the book-club category. -->
<?php $bc_query = new WP_Query('category_name=book-club&showposts=1'); ?>
<?php while ($bc_query->have_posts()) : $bc_query->the_post(); ?>
<a href="<?php the_permalink(); ?>" alt="Read more about the next book club meeting." title="Read more about the next book club meeting."><?php the_excerpt(); ?></a>
<?php endwhile;?>
</li>
…and yes, I know the_excerpt() creates paragraph tags, and anchor tags around paragraph tags probably doesn’t validate. Oh well.
…the 2 year anniversary of the day that florence and I met.
…the first day of national poetry month.
…April Fools day.
…the day I upgraded to livingtech.net to Wordpress 2.5.
…the first day… of the rest of my life.
…nothing special.
…the most special day EVER.
…getting old already.
…more than half over.
…a clusterfuck of ellipses.
…just another word that means time has passed and our lives are ceaselessly marching into the future regardless of hesitation or observation or introspection.
…beautiful.
I have been too lazy to change this default theme. Soon. maybe. someday. possibly.
In the mean time, enjoy this braindump I haven’t actually typed up yet.