Bottled Water Bollocks | Home | 20th Sep 06: Danika at Pike Place Market

Goodbye 3 hours

I’ve made a couple of very minor updates to bluefacedpixie. It was a lesson, as always, in humility and a sharp reminder that doing simple geek-things is often harder than expected. More after the (more).

For a while I was wanting to display mostly chronological entries in my blog by title only. Originally I thought it would be a good little “hack my aging Wordpress 1.5.x installation” exercise to let me putter about with PHP. So as Danika napped tonight I started into it. Almost immediately I was impressed though that Wordpress has thought of all this before and a combination of get_archives("type=monthly') in the sidebar.php and the addition of an archive.php to customize the index.php display (so I could then add in title only display rather than post display) would do the trick. So I decided to do it the “wordpress way”.

And it’s mostly done now. There’s a new section in the sidebar for Ancient History that will take you to a simpler title listing, and as a “feature” this also works for categories due to the Wordpress template code. It actually looks good but isn’t what I was originally expecting (I thought the category-X.php files overrode that display).

I also tidied up a few things in the sidebar and tried to the move the verbose “you are now browsing…” string to the main page before leaving it in the sidebar in a new position.

It took much longer than expected, but I got there – one hour turned into three (with a little blog at the end of course).

The most significant hoop:

I wanted to display as many titles as I could per page (limited to 100, just in case…) and this required me to add this code before The Loop:

< ?php $query_string = "posts_per_page=100&" . $query_string;
query_posts($query_string);
?>

So I’m basically hacking into the global variable ($query_string) that was used to set up the initial query, adding my restriction and rerunning it (query_posts()) before the loop. Not efficient (as query_posts() fires twice, once in Wordpress, again in the template) but necessary to override the first question. It doesn’t work quite right though as….

The show_page variable isn’t processed correctly in the “Next Page” logic – it appears a “Next Page” will always appear and (if there are less than 100 posts) move onto a page with no results. Bad, but liveable.

A final bugette seems to be the get_excerpt() call, initially I wanted to use this with title= on the blog titles to get a popover effect, however the get_excerpt() doesn’t strip HTML, giving an ugly display (it is meant to) so I skipped it in this iteration.

All in all – Wordpress surprises once more, but not quite as easily as I’d like, but I’d be faster with more familiarity.

Epilogue: As my much hacked template is based on the GPL’d Plain Vanilla, contact me if you want a complete copy of the theme.