Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
2 of 4 Improved the title.

Static counter in a loop with nested functions

I have used $count before, but never run into this problem. I cannot get it to work. I have limited php background, so please be patient with me! Here is the $count setup code:

<?php $count = 0; ?>
<?php if ( have_posts() ) : // Start the Loop ?>
    <?php $count++; ?>      
    <?php while ( have_posts() ) : the_post(); ?>
        <?php get_template_part( 'content', get_post_format() ); ?>
    <?php endwhile; ?>  
<?php endif; ?>

Within content.php - here is what I am trying to do:

<?php if ($count == 1) { ?>
    <section class="stories-title">
        <img src="<?php bloginfo('stylesheet_directory'); ?>/assets/stories-title.jpg" />
    </section>
<?php ;} ?>

Can anyone explain to me what's happening? To the best of my knowledge, I'm running into an undefined variable issue, but I'm not sure how to fix this without breaking the $count... do the conditional statements and content have to be in the same file for $count to work?