I am trying to use an if statement with is_category() in order to build a bigger piece of code later. I can’t get the code to recognize the if statement though. Basically below I’ve posted the coding with the if statement commented out. It works without the if statement but if I uncomment the if statement (and the closing curly bracket) then there is an error and the page doesn’t display. I am only checking this on a category page so I assumed it should recognize that it is a category page and display the posts (I can understand it being a problem if I was on a ‘tag’ archive page, etc.). Why would this have a problem displaying?
<?php
/*if (is_category()) {*/
if ($paged == 0)
$offset = 0;
else
$offset = ($paged - 1) * 11;
global $post;
$category = get_the_category($post->ID);
$category = $category[0]->cat_ID;
$myposts = get_posts(array('numberposts' => 11, 'offset' => $offset, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish'));
foreach($myposts as $post) :
setup_postdata($post);
/*}*/
?>