The following code is placed inside an include file named latest-web.php :

<?php
                    $args = array( 'numberposts' => '8', 'category_name' => 'web-reference' );
                    $recent_posts = wp_get_recent_posts( $args );
                    foreach( $recent_posts as $recent ){
                        $featured_image = get_the_post_thumbnail();
                        $poveznica = get_field('link-projekta');
                        echo '<figure class="effect-winston">
                        ' . $featured_image . '
                        <figcaption>
                            <h2><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"] . '</a></h2>
                            <p>
                                <a href="' . get_permalink($recent["ID"]) . '"><i class="fa fa-fw fa-list"></i></a>
                                <a href="' . $poveznica . '" target="_blank"><i class="fa fa-fw fa-link"></i></a>
                            </p>
                        </figcaption>           
                    </figure>';
                    }
                    wp_reset_query();
?>

When including the file in index.html, it works flawlessly, but when including it in the page template, there is a problem. The code pulls all the info correctly. However, the image/thumbnail is not displayed at all. There is no img tag when inspecting from the browser. Does anyone have a solution for this?

Thanks!

Read more here: get_the_post_thumbnail() not working in a page template


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: