title: the_post_thumbnail in WordPress Loop wont work
body: <p>I'm new too this, and I can't get my loop to show the featured image from posts in WordPress. </p>
  
  <p>I have tried with the_post_thumbnail and 
  looked through <a href="https://codex.wordpress.org/Post_Thumbnails" rel="nofollow noreferrer">https://codex.wordpress.org/Post_Thumbnails</a> and other similar questions.</p>
  
  <p>Hope you can help.</p>
  
  <p>My loop looks like this now:</p>
  
  <pre><code>  &lt;?php
    $query = new WP_Query(array(
        'posts_per_page'   =&gt; 4,
    ));
  
    while ($query-&gt;have_posts()): $query-&gt;the_post(); ?&gt;
       &lt;ul&gt;
           &lt;li&gt;&lt;?php the_title(); ?&gt;&lt;/li&gt;
           &lt;li&gt;&lt;?php echo get_the_date(); ?&gt;&lt;/li&gt;
           &lt;li&gt;&lt;?php
              if ( has_post_thumbnail() ) {
                  the_post_thumbnail('thumbnail');
              } ?&gt;
           &lt;/li&gt;
       &lt;/ul&gt;
    &lt;?php endwhile;
    wp_reset_postdata();
    ?&gt;
  </code></pre>