• I’m using a slightly modified twentyten theme. In the index.php, The only real change is that after get_header(), I have query_posts(‘cat=4’)

    I want to style my posts with a bottom border, but not for the last post, so in the loop.php I replaced

    while ( have_posts() ) : the_post();

    with

    $postCount = 0;
    while ( have_posts() ) : the_post();
    ++$postCount;
    if( $postCount == count($posts) )
    {
    	$lastPost = 'last-post';
    }
    else
    {
    	$lastPost = 'not-last-post';
    }

    I then apply the class with post_class(). The problem is, that I have only three posts, but count($posts) returns 4. Why? What can I do to make sure I know how many posts are actually being displayed?

  • The topic ‘count of $post is larger than actual posts on front page’ is closed to new replies.