Well… Of course it doesn’t work – $count
is undefined and you never change it’s value.
You probably want to have there something like this:
<?php if ($loop) : while ($loop->have_posts()) : $loop->the_post(); ?>
<li class="grid_4 portfolio-post">
<?php if ($loop->current_post == 0) echo '<div class="newest">NEW</div>'; ?>
<a href="https://wordpress.stackexchange.com/questions/138934/<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<header class="post-thumb">
<?php the_post_thumbnail('thumbnail-portfolio'); ?>
</header><!-- End header.post-thumb -->
<aside>
<h2><?php the_title(); ?></h2>
<p><?php the_excerpt(); ?></p>
</aside><!-- End aside -->
</a>
</li><!-- End li.grid_4 portfolio-post -->
<?php endwhile; ?>
<?php else : ?>
<p>No portfolio items were found! I'm not sure what you're looking for.</p>
<?php endif; ?>
<?php wp_reset_query(); ?>
</ul><!-- End ul.entrybox -->
WP_Query
already has it’s own counter (current_post
), so you don’t have to define your own.