has_post_thumbnail() not working on pages
<p>im reusing some code i used on the index.php in my wordpress theme. Everything works, except of the thumbnails (which work on index.php). 
I can display them.
But if i try to check via (has_post_thumbnail()) it always returns false.
Where could be the problem? </p>

<p>The problem is in the following part:</p>

<pre><code>if ( has_post_thumbnail() ) {
                        $photo = get_the_post_thumbnail( $recent['ID'], 'large' );
                        echo  '&lt;div class="section1-2singlephoto"&gt;' . $photo . '&lt;/div&gt;';
                    }

                    else {
                        echo 'no Thumbnail';
                    }
</code></pre>

<p>Only using the following code would work:</p>

<pre><code>                    $photo = get_the_post_thumbnail( $recent['ID'], 'large' );
                    echo  '&lt;div class="section1-2singlephoto"&gt;' . 
</code></pre>

<p>Can anybody give me a hint why this might not be working. 
I made a page a page template and added the code into it. 
Here is the full code:</p>

<pre><code> &lt;?php
            $args = array( 'numberposts' =&gt; '20',
                'offset'    =&gt; '1'
            );
            $recent_posts = wp_get_recent_posts( $args );
            foreach( $recent_posts as $recent ){




                echo '&lt;div class="section1-2single large-12 medium-12 small-12 column"&gt;';

                echo '&lt;a class="" href="' . get_permalink($recent["ID"]) . '"&gt;&lt;h4&gt;' . $recent["post_title"] .'&lt;/h4&gt;&lt;/a&gt;';


                echo '&lt;div class="large-12 medium-12 small-12 row"&gt;';

                echo '&lt;div class="large-2 medium-2 small-2 columns"&gt;';

                // GET COMMENTS NUMBER
                $comments_count = wp_count_comments( $recent["ID"] );
                echo '&lt;div class=metaDataContainer&gt;';
                if ($comments_count-&gt;total_comments === 0) {
                    echo '&lt;i class="fa fa-comment-o commentsNumbre"&gt; 0&lt;/i&gt;';
                };
                if ($comments_count-&gt;total_comments === 1) {
                    echo '&lt;i class="fa fa-comment-o commentsNumbre"&gt; '. $comments_count-&gt;total_comments .'&lt;/i&gt;';
                };
                if ($comments_count-&gt;total_comments &gt; 1) {
                    echo '&lt;i class="fa fa-comment-o commentsNumbre"&gt; '. $comments_count-&gt;total_comments .'&lt;/i&gt;';
                };

                echo do_shortcode('[mashshare text="'. $recent["post_title"] .'" url="'. get_permalink($recent["ID"]) .' shares="false" align="center" "]');

                echo '&lt;/div&gt;';
                echo '&lt;/div&gt;';


                echo '&lt;div class="large-10 medium-10 small-10 columns"&gt;';
// GET THE THUMBNAIL
                if ( has_post_thumbnail() ) {
                    $photo = get_the_post_thumbnail( $recent['ID'], 'large' );
                    echo  '&lt;div class="section1-2singlephoto"&gt;' . $photo . '&lt;/div&gt;';
                }

                else {
                    echo 'no Thumbnail';
                }

                $content = wpautop($recent['post_content']);
                $trimmed_content = wp_trim_words( $content, 60, '...' );
                ;
                echo '&lt;div class="trimmedContent"&gt;' . $content .'&lt;/div&gt;';
                echo '&lt;a class="button section1-2single-button" href="'. get_permalink($recent["ID"]) .'"&gt;weiter&lt;/a&gt;';

                echo '&lt;/div&gt;';

                echo '&lt;/div&gt;';

                echo '&lt;/div&gt;';



            }

            ?&gt;
</code></pre>