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);

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

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