Skip to main content
1 of 4
nikibrown
  • 71
  • 1
  • 3
  • 10

if in_category on archive.php

So I'm trying to do an if / else statement on an archive.php template. I setting up my archives using WP Smart archives reloaded (http://wordpress.org/extend/plugins/smart-archives-reloaded/)

The code from my archive.php is as follows:

<?php
   if (in_category('166')) { include 'archive-blog.php';
}

else {
   echo('foo');
}
?>

Im trying to get archive.php to include a certain template based on the category number. However this code grabs the archive blog template no matter what (even if I click on a category archive that is not the blog).

I'm wondering if I'm not doing this correctly - does in_category not work on an archive page? I have a similar set up with a single.php directing to a different include template based on the category.

Thanks!

nikibrown
  • 71
  • 1
  • 3
  • 10