I'm trying to display thumbnails inside a div from a query, but the thumbnail is outside the div and I don't know what I'm doing wrong, here is my code:
<?php
// WP_Query arguments
$args = array(
'post__in' => array(26844,26829),
'post_type' => array( 'wedstrijd' ),
'post_status' => array( 'published' ),
);
// The Query
$shquery = new WP_Query( $args );
// The Loop
if ( $shquery->have_posts() ) {
while ( $shquery->have_posts() ) {
$shquery->the_post();
echo '<div class="wed_thumb">' . the_post_thumbnail('et-pb-post-main-image') . '</div>';
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
I'm trying to display thumbnails inside a div from a query, but the thumbnail is outside the div and I don't know what I'm doing wrong, here is my code:
<?php
// WP_Query arguments
$args = array(
'post__in' => array(26844,26829),
'post_type' => array( 'wedstrijd' ),
'post_status' => array( 'published' ),
);
// The Query
$shquery = new WP_Query( $args );
// The Loop
if ( $shquery->have_posts() ) {
while ( $shquery->have_posts() ) {
$shquery->the_post();
echo '<div class="wed_thumb">' . the_post_thumbnail('et-pb-post-main-image') . '</div>';
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
Share
Improve this question
edited Oct 16, 2019 at 11:47
fuxia♦
107k39 gold badges255 silver badges459 bronze badges
asked Oct 16, 2019 at 10:54
BielsBiels
1134 bronze badges
1 Answer
Reset to default 1the_post_thumbnail
will echo it, You should Use get_the_post_thumbnail
instead to return image.