• Hi all,
    I’m struggling to think of a way to link categories in my blog to custom archive templates.

    What I’d like to achieve is multiple different archive.php templates, allowing each category to have a specific matching archive template in the same way that you can have category-xx.php templates for each category.

    You could imagine that I’d end with template files like ‘archive-61.php’ linked to ‘category-61.php’.

    The archive widget needs to match as well, so if I’m in category 61 then the archive widget lists only months that have posts in category 61 and clicking on the month would take me to an archive page using archive-61.php template and showing only posts in category 61.

    Thanks to the 2.8 widget API making an archive widget based on a single category was pretty easy, but I’m a bit stuck on how to link to multiple archive templates from it.

    I can use add_filter(‘archive_template’, xxx); to put custom rules in the archive template selection code, but the only way I can think to get that to work is to check the referring URL for a querysting or URL format – I suspect some rewrite rules would be the answer here…

    Has anyone done this before or got any suggestions???
    Am I missing something stupidly obvious???

  • The topic ‘Link a specific category to a matching archive template?’ is closed to new replies.