Displaying specific posts from query thumbnail outside div

I'm trying to display thumbnails inside a div from a query, but the thumbnail is outside the div and I don't k

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
Add a comment  | 

1 Answer 1

Reset to default 1

the_post_thumbnail will echo it, You should Use get_the_post_thumbnail instead to return image.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745076525a4609868.html

相关推荐

  • Displaying specific posts from query thumbnail outside div

    I'm trying to display thumbnails inside a div from a query, but the thumbnail is outside the div and I don't k

    16小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信