Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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);
/*}*/
?>
share|improve this question
    
where is that code in the context of the whole template? –  Michael Jul 25 '12 at 23:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.