Making a magazine in WordPress: Issues

I’m currently making a WordPress magazine site. Among other things, it needs to show only the posts from the current issue on the front page. It uses categories to mark which issue an article belongs to.

I thought I’d share the code to do this, as it may be of use to some of you. This code sits just before your loop in index.php. It takes all categories under category 8 (the ‘Issues’ category for the magazine), gets the ID of the most recently added category under these and then sets the query to use that.

Please use at your own risk, etc:

$category = get_categories('child_of=8&order=DESC');
$category = array_values($category);
query_posts('cat=' . $category[0]->cat_ID);

Hi. I live here to keep the peace. You can ignore me now :)