Since I deactivated Extended Live Archives for this blog (because nobody really used it and it adds code and style sheets to the page) I played around with some code from the web to generate a Wordpress archive page which would group together years and months of blog posts (yeah, I can really speak of “years” and “months”, Stopbeingcarbon.com is now over three years old).
One drawback I found by accident is the query number for this specific code. years*12+n (which results in about 600 queries for my blog). Not so good.
So I had a look at my mysql logs and found a reoccurring line which selects a single post via an id. Googling brought up some results with get_permalink() as the malefactor. The get_permalink() function takes an id of a blog post and returns the permalink. Which is nice, but I already had the post, I just needed the permalink.
By copying the function, removing one line (the post-loading-thing) and renaming the argument I had a new function which would give me the permalink from a post object. Outcome: query count is down to one tenth and I’m happy (as well as my db server).

1 comment
Comments feed for this article
Trackback link
http://www.stopbeingcarbon.com/2007/07/wordpress-archives/trackback/
October 27, 2008 at 3:51
Pingback from Blog Roundup for the 16th of July 2007 :: Christopher Ross