Wordpress / PHP:获取循环外变量的值

In my WordPress template (that I am developing), I have the header.php and a template part named header-head.php (called in the header.php). At the index.php, I have other template parte named content.php (called in the index.php). I am trying to get a information of the first post of the taxonomy (named feeling) that I created and return the value in the header-head.php.

The content.php code:

$terms = get_the_terms($post->ID, 'feeling');
foreach ($terms as $term) {
    //Always check if it's an error before continuing. get_term_link() can be finicky sometimes
    $term_link = get_term_link( $term, 'feeling' );
    if( is_wp_error( $term_link ) )
        continue;
    //We successfully got a link. Print it out.
    $term_return = '<a href="' . $term_link . '">Feeling ' . $term->name . '</a>';
}

if ( has_term( '', 'feeling' ) AND $count == 0 ) {
    $latest_feeling = "<p class='feeling-text'>" . $term_return . "</p>";
    $GLOBALS['feeling_post'] = $latest_feeling;
}

The header-head.php code:

$feeling_return = $GLOBALS['feeling_post'];
echo $feeling_return;

You may have noticed the variable $count, it count the number of posts to check for the first post. I did it in the index.php file and then got the value in the content.php file using $GLOBALS, but now I am not getting...

The index.php loop code:

<?php if ( have_posts() ) : ?>
    <?php $count = 0; ?>

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>
        <?php $GLOBALS['count_post'] = $count++; ?>

            <?php
                /* Include the Post-Format-specific template for the content.
                 */
                get_template_part( 'partials/content', get_post_format() );
            ?>

        <?php endwhile; ?>

        <?php sensibus_paging_nav(); ?>

    <?php else : ?>

        <?php get_template_part( 'partials/content', 'none' ); ?>

    <?php endif; ?>

Can someone help me? What am I doing wrong?