• Warning: Invalid argument supplied for foreach() in /var/www/html/wordpress/wp-includes/template-functions-category.php on line 393
    and
    Warning: in_array(): Wrong datatype for second argument in /var/www/html/wordpress/wp-includes/template-functions-category.php on line 397

    I want to get only those posts displayed that are in a certain category (before i’ve already selected posts from certain time range). I’m using that kind of loop:
    <?php if($my_posts) : foreach($my_posts as $post) : setup_postdata($post); ?>
    <?php if(in_category(’11’)) { ?>
    //displays posts
    <?php } ?>
    <?php endforeach; endif; ?>

    what could be the problem? i haven’t edited my template-functions-category.php file.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try this <?php if (in_category('11')): { ?>

    Thread Starter siim

    (@siim)

    no, this returns a parse error:
    Parse error: parse error, unexpected T_ENDFOREACH in /var/www/html/wordpress/wp-content/themes/default/uudiskiri_2.php on line 35
    if using

    <?php if(in_category('11')) : ?>
    //displays posts
    <?php endif; ?>
    <?php endforeach; endif; ?>

    then it’s the same error that i had in the beginning (see the first post)
    really weird 🙁

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘in_category returns error’ is closed to new replies.