I have created a post with featured image from the Add New Post section, and now I want to retrieve the post with it’s thumbnail , summary and the title.
The other fields are displayed just fine (title, and Summary) the way I want, however nothing can be retrieved for the thumbnail. Here is the code I’m using :
<?php
$args = array( 'posts_per_page' => 1, 'order'=> 'DESC','category' => 'watch', 'orderby' => 'post_date','offset' => 1, );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<td class="leftBoxes">
<!--IMAGE- THIS IS the Problem -->
<div class="imgMargin"> <?php get_the_post_thumbnail(); ?> </div>
<br>
<div class="boxScrollsBlogsView">
<h2><?php the_title(); ?> </h2>
<P>
<?php the_excerpt(); ?>
</P>
</div>
</td>
<?php endforeach; ?>
I added this line to the function.php as well
add_theme_support( 'post-thumbnails' );
and I can see the image when I click on single-post view, to check if it is added to the db or not.
But it just doesn’t come up in the custom page that I’ve created.
I think you are supposed to
echo
it as the functions return strings. E.G.:Try this one: